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.

            
              <!-- Showcasing how we can interpolate between any two values over a set of breakpoints-->
<!-- From $small: Blue goes from 20px padding to 100px padding and stops at $large -->
<!-- From $small: Black goes from 100px height to 20px height and stops $large -->

<div class="Container">
  <div class="Element"></div>
</div>
            
          
!
            
              /**
 * Computes a CSS calc function that betweens a value from
 * A to B over viewport-width A to viewport-width B.
 * Requires a media query to cap the value at B.
 */
 
@function between($to, $from, $toWidth, $fromWidth) {
  $slope: ($to - $from) / ($toWidth - $fromWidth);
  $base: $from - $slope * $fromWidth;

  @return calc(#{$base} + #{100vw * $slope});
}

$small: 400px; 
$large: 1000px;

* {
  box-sizing: inherit;
}

html, body {
  box-sizing: border-box;
}

.Container {
  align-items: center;
  background-color: #0087be;
  border: 10px solid #f25292;
  display: flex;
  padding: 20px;

  @media (min-width: $small) {
    padding: between(20px, 100px, $small, $large);
  }

  @media (min-width: $large) {
    padding: 100px;
  }
}

.Element {
  background-color: #252A34;
  border-radius: 3px;
  height: 100px;
  width: 100%;
  
  @media (min-width: $small) {
   height: between(100px, 20px, $small, $large);
  }

  @media (min-width: $large) {
   height: 20px;
  }
}
            
          
!
999px
Close

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.

Go PRO

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

Console