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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

            
              <div class="info">
  <h1>Retina Image Mixin & Media Query</h1>
  <p>Easily replace background images in css with their @2x version.</p>
  <div class="bot">
    <div class="non"></div>
    <div class="retina"></div>
  </div>
  <p class="links"><a href="https://twitter.com/michaelarestad" target="_blank">@michaelarestad</a> // <a href="https://twitter.com/see8ch" target="_blank"/>@see8ch</a>
</div>

<div class="demo non"></div>
<div class="demo retina"></div>
            
          
!
            
              @import "compass/css3";

//  Retina Image Mixin & Media Query
//  Authors: 
//  Michael Arestad @michaelarestad
//  Chris Holder @see8ch


@mixin retina-background ($url, $file-type, $width: auto, $repeat: repeat, $ratio: 1.5, $suffix: "@2x") {
	
  background: url($url + "." + $file-type);
  background-repeat: $repeat;
  
  /* Media queries from https://github.com/thoughtbot/bourbon/blob/master/app/assets/stylesheets/css3/_hidpi-media-query.scss */
	@media only screen and (-webkit-min-device-pixel-ratio: $ratio),
    only screen and (min--moz-device-pixel-ratio: $ratio),
    only screen and (-o-min-device-pixel-ratio: #{$ratio}/1),
    only screen and (min-resolution: #{round($ratio*96)}dpi),
    only screen and (min-resolution: #{$ratio}dppx) {
		
    background: url($url + $suffix + "." + $file-type);
		background-size: $width auto;
	}
}







//  Demo Stuff
$bkgd-color: #16a085;
$shadow: darken($bkgd-color, 12%);

.info {
  position: relative;
  z-index: 2;
  width: 800px;
  margin: 50px auto;
  background: $bkgd-color;
  padding: 15px 0;
  text-align: center;
  font-family: 'helvetica';
  color: #ecf0f1;
  box-shadow: 7px 6px 0 $shadow;
  
  h1 {
    text-shadow: 2px 3px 0 $shadow;
  }
  p {
    margin-bottom: 35px;
  }
  
  .links {
    color:$shadow; 
    margin-bottom:5px;
    font-size:smaller;
  }
  
  a {  
    color:$shadow;    
    transition: all 400ms ease-in-out; 
    
    &:hover {color:#ecf0f1;}
  }
}
.bot {
  position: relative;
  width: 800px;
  height: 295px;
  border-top: 7px solid darken($shadow, 15%);
  border-bottom: 7px solid darken($shadow, 15%);
  
  .non,
  .retina {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 70%;
  }
  .non {
    background: url(http://michaelarestad.com/images/misc/bot.jpg);
    z-index: 1;
    border-right: 1px rgba(255,255,255,.8) solid;
    overflow: hidden;
    resize: horizontal;
    max-width: 800px;
  }
  .retina {
    left: 0;
    right: 0;
    @include retina-background('http://michaelarestad.com/images/misc/bot',jpg, 800px);
  }
}
.demo {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 50%;
}
.demo.non {
  background: url(http://www.see8ch.com/codepen/tiny_grid.png);
  z-index: 1;
  border-right: 2px #2980b9 solid;
  overflow: hidden;
  resize: horizontal;
}
.demo.retina {
  left: 0;
  right: 0;
  @include retina-background('http://www.see8ch.com/codepen/tiny_grid',png, 26px);
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console