cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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
              @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;


Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.


Loading ..................