cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <section class="section">
  The box changes background color depending on viewport width
</section> 
            
          
!
            
              @import "compass/css3";

/**
* Conditional Media Query Mixin
* by @sheiko (http://dsheiko.com)
* 
* The problem this mixin solves is explained there 
* https://css-tricks.com/conditional-media-query-mixins/
*
* https://github.com/dsheiko
* MIT license: https://www.opensource.org/licenses/mit-license.php
*/


// Predefined Break-points
$mediaMaxWidth: 1260px;
$mediaBp1Width: 960px;
$mediaMinWidth: 480px;

@function translate-media-condition($c) {
  $condMap: (
		"screen": "only screen",
		"print": "only print",
		"retina": "(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-device-pixel-ratio: 1.5), (min-resolution: 120dpi)",
     ">maxWidth": "(min-width: #{$mediaMaxWidth + 1})",
		"<maxWidth": "(max-width: #{$mediaMaxWidth})", 		
		">bp1Width": "(min-width: #{$mediaBp1Width + 1})",
		"<bp1Width": "(max-width: #{$mediaBp1Width})",
		">minWidth": "(min-width: #{$mediaMinWidth + 1})",
		"<minWidth": "(max-width: #{$mediaMinWidth})"
	);
  @return map-get( $condMap, $c );
}

// The mdia mixin
@mixin media($args...) {
  $query: "";
  @each $arg in $args {
    $op: "";
    @if ( $query != "" ) {
      $op: " and ";
    }
    $query: $query + $op + translate-media-condition($arg);
  }
  @media #{$query}  { @content; }
}

/**
 * Usage examples
 */
.section {
  border: 2px solid #777;
  padding: 40px;
  background: silver;
  @include media( "retina" ){
    border: 2px dotted #000;
  };
  @include media( "screen", ">bp1Width", "<maxWidth" ){
    background: red;
    color: white;
  };
	@include media( "screen", ">minWidth", "<bp1Width" ){
    background: green;
    color: white;
  };
	@include media( "screen", "<minWidth" ){
    background: blue;
    color: white;
  };
}


            
          
!
999px
Loading ..................

Console