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.

            
              @import url('https://fonts.googleapis.com/css?family=Kaushan+Script');

html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  font-size: 10px;
  background: linear-gradient(to bottom right, dodgerblue 50%, darken(dodgerblue, 5%) 50%);
}

$yellow: mix(yellow, orange, 50%);

.ruler {
  position: relative;
  margin: auto;
  border-radius: 0.5em;
  border: black solid 0.25em;
  width: 25em;
  height: 8em;
  box-shadow:
    inset 0 0.25em rgba(white, 0.7),
    inset 0 1.5em rgba(white, 0.3),
    inset 0 -1.5em rgba(black, 0.1),
    inset 0 -0.25em rgba(black, 0.1)
  ;
  background:
    linear-gradient(to bottom, $yellow 4em, rgba($yellow, 0) 4em) no-repeat,
    linear-gradient(
      to right,
      rgba(black, 0) 5em, black 5em, black calc(5em + 1px), rgba(black, 0) calc(5em + 1px),
      rgba(black, 0) 10em, black 10em, black calc(10em + 1px), rgba(black, 0) calc(10em + 1px),
      rgba(black, 0) 15em, black 15em, black calc(15em + 1px), rgba(black, 0) calc(15em + 1px),
      rgba(black, 0) 20em, black 20em, black calc(20em + 1px), rgba(black, 0) calc(20em + 1px)
    ) no-repeat,
    linear-gradient(to bottom, $yellow 6em, rgba($yellow, 0) 6em) no-repeat,
    linear-gradient(
      to right,
      rgba(black, 0) 2.5em, black 2.5em, black calc(2.5em + 1px), rgba(black, 0) calc(2.5em + 1px),
      rgba(black, 0) 7.5em, black 7.5em, black calc(7.5em + 1px), rgba(black, 0) calc(7.5em + 1px),
      rgba(black, 0) 12.5em, black 12.5em, black calc(12.5em + 1px), rgba(black, 0) calc(12.5em + 1px),
      rgba(black, 0) 17.5em, black 17.5em, black calc(17.5em + 1px), rgba(black, 0) calc(17.5em + 1px),
      rgba(black, 0) 22.5em, black 22.5em, black calc(22.5em + 1px), rgba(black, 0) calc(22.5em + 1px)
    ) no-repeat,
    $yellow;
}

.ruler::before,
.ruler::after {
  display: block;
  position: absolute;
  text-align: center;
  left: 0;
  right: 0;
  color: white;
  font-size: 3em;
  font-family: 'Kaushan Script', cursive;
}

.ruler::before {
  content: 'Need a ruler?';
  bottom: calc(100% + 2rem);
}

.ruler::after {
  content: 'Print this page!';
  top: calc(100% + 2rem);
}

@function unit($val) {
  @return ($val * 72) * 1px;
}

@media print {
  body {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    font-size: 10pt;
    background: transparent none;
    zoom: 1;
  }

  .ruler {
    overflow: hidden;
    text-indent: -9999999em;
    position: absolute;
    display: block;
    top: calc(50% - #{unit(3)});
    left: calc(50% - #{unit(0.75)});
    height: unit(6);
    width: unit(1.5);
    border-radius: 0;
    box-shadow: 0 0 0 4px black;
    background:
      linear-gradient(to left, white unit(0.75), rgba(white, 0) unit(0.75)) no-repeat center left,
      linear-gradient(
        to bottom,
        rgba(black, 0) unit(1), black unit(1), black calc(#{unit(1)} + 1px), rgba(black, 0) calc(#{unit(1)} + 1px),
        rgba(black, 0) unit(2), black unit(2), black calc(#{unit(2)} + 1px), rgba(black, 0) calc(#{unit(2)} + 1px),
        rgba(black, 0) unit(3), black unit(3), black calc(#{unit(3)} + 1px), rgba(black, 0) calc(#{unit(3)} + 1px),
        rgba(black, 0) unit(4), black unit(4), black calc(#{unit(4)} + 1px), rgba(black, 0) calc(#{unit(4)} + 1px),
        rgba(black, 0) unit(5), black unit(5), black calc(#{unit(5)} + 1px), rgba(black, 0) calc(#{unit(5)} + 1px)
      ) no-repeat center left,
      linear-gradient(to left, white unit(1), rgba(white, 0) unit(1)) no-repeat center left,
      linear-gradient(
        to bottom,
        rgba(black, 0) unit(0.5), black unit(0.5), black calc(#{unit(0.5)} + 1px), rgba(black, 0) calc(#{unit(0.5)} + 1px),
        rgba(black, 0) unit(1.5), black unit(1.5), black calc(#{unit(1.5)} + 1px), rgba(black, 0) calc(#{unit(1.5)} + 1px),
        rgba(black, 0) unit(2.5), black unit(2.5), black calc(#{unit(2.5)} + 1px), rgba(black, 0) calc(#{unit(2.5)} + 1px),
        rgba(black, 0) unit(3.5), black unit(3.5), black calc(#{unit(3.5)} + 1px), rgba(black, 0) calc(#{unit(3.5)} + 1px),
        rgba(black, 0) unit(4.5), black unit(4.5), black calc(#{unit(4.5)} + 1px), rgba(black, 0) calc(#{unit(4.5)} + 1px),
        rgba(black, 0) unit(5.5), black unit(5.5), black calc(#{unit(5.5)} + 1px), rgba(black, 0) calc(#{unit(5.5)} + 1px)
      ) no-repeat center left,
      linear-gradient(to left, white unit(1.25), rgba(white, 0) unit(1.25)) no-repeat center left,
      linear-gradient(
        to bottom,
        rgba(black, 0) unit(0.25), black unit(0.25), black calc(#{unit(0.25)} + 1px), rgba(black, 0) calc(#{unit(0.25)} + 1px),
        rgba(black, 0) unit(0.75), black unit(0.75), black calc(#{unit(0.75)} + 1px), rgba(black, 0) calc(#{unit(0.75)} + 1px),
        rgba(black, 0) unit(1.25), black unit(1.25), black calc(#{unit(1.25)} + 1px), rgba(black, 0) calc(#{unit(1.25)} + 1px),
        rgba(black, 0) unit(1.75), black unit(1.75), black calc(#{unit(1.75)} + 1px), rgba(black, 0) calc(#{unit(1.75)} + 1px),
        rgba(black, 0) unit(2.25), black unit(2.25), black calc(#{unit(2.25)} + 1px), rgba(black, 0) calc(#{unit(2.25)} + 1px),
        rgba(black, 0) unit(2.75), black unit(2.75), black calc(#{unit(2.75)} + 1px), rgba(black, 0) calc(#{unit(2.75)} + 1px),
        rgba(black, 0) unit(3.25), black unit(3.25), black calc(#{unit(3.25)} + 1px), rgba(black, 0) calc(#{unit(3.25)} + 1px),
        rgba(black, 0) unit(3.75), black unit(3.75), black calc(#{unit(3.75)} + 1px), rgba(black, 0) calc(#{unit(3.75)} + 1px),
        rgba(black, 0) unit(4.25), black unit(4.25), black calc(#{unit(4.25)} + 1px), rgba(black, 0) calc(#{unit(4.25)} + 1px),
        rgba(black, 0) unit(4.75), black unit(4.75), black calc(#{unit(4.75)} + 1px), rgba(black, 0) calc(#{unit(4.75)} + 1px),
        rgba(black, 0) unit(5.25), black unit(5.25), black calc(#{unit(5.25)} + 1px), rgba(black, 0) calc(#{unit(5.25)} + 1px),
        rgba(black, 0) unit(5.75), black unit(5.75), black calc(#{unit(5.75)} + 1px), rgba(black, 0) calc(#{unit(5.75)} + 1px)
      ) no-repeat center left,
      linear-gradient(to left, white unit(1.325), rgba(white, 0) unit(1.325)) no-repeat center left,
      linear-gradient(
        to bottom,
        rgba(black, 0) unit(0.125), black unit(0.125), black calc(#{unit(0.125)} + 1px), rgba(black, 0) calc(#{unit(0.125)} + 1px),
        rgba(black, 0) unit(0.375), black unit(0.375), black calc(#{unit(0.375)} + 1px), rgba(black, 0) calc(#{unit(0.375)} + 1px),
        rgba(black, 0) unit(0.625), black unit(0.625), black calc(#{unit(0.625)} + 1px), rgba(black, 0) calc(#{unit(0.625)} + 1px),
        rgba(black, 0) unit(0.875), black unit(0.875), black calc(#{unit(0.875)} + 1px), rgba(black, 0) calc(#{unit(0.875)} + 1px),
        
        rgba(black, 0) unit(1.125), black unit(1.125), black calc(#{unit(1.125)} + 1px), rgba(black, 0) calc(#{unit(1.125)} + 1px),
        rgba(black, 0) unit(1.375), black unit(1.375), black calc(#{unit(1.375)} + 1px), rgba(black, 0) calc(#{unit(1.375)} + 1px),
        rgba(black, 0) unit(1.625), black unit(1.625), black calc(#{unit(1.625)} + 1px), rgba(black, 0) calc(#{unit(1.625)} + 1px),
        rgba(black, 0) unit(1.875), black unit(1.875), black calc(#{unit(1.875)} + 1px), rgba(black, 0) calc(#{unit(1.875)} + 1px),
        
        rgba(black, 0) unit(2.125), black unit(2.125), black calc(#{unit(2.125)} + 1px), rgba(black, 0) calc(#{unit(2.125)} + 1px),
        rgba(black, 0) unit(2.375), black unit(2.375), black calc(#{unit(2.375)} + 1px), rgba(black, 0) calc(#{unit(2.375)} + 1px),
        rgba(black, 0) unit(2.625), black unit(2.625), black calc(#{unit(2.625)} + 1px), rgba(black, 0) calc(#{unit(2.625)} + 1px),
        rgba(black, 0) unit(2.875), black unit(2.875), black calc(#{unit(2.875)} + 1px), rgba(black, 0) calc(#{unit(2.875)} + 1px),
        
        rgba(black, 0) unit(3.125), black unit(3.125), black calc(#{unit(3.125)} + 1px), rgba(black, 0) calc(#{unit(3.125)} + 1px),
        rgba(black, 0) unit(3.375), black unit(3.375), black calc(#{unit(3.375)} + 1px), rgba(black, 0) calc(#{unit(3.375)} + 1px),
        rgba(black, 0) unit(3.625), black unit(3.625), black calc(#{unit(3.625)} + 1px), rgba(black, 0) calc(#{unit(3.625)} + 1px),
        rgba(black, 0) unit(3.875), black unit(3.875), black calc(#{unit(3.875)} + 1px), rgba(black, 0) calc(#{unit(3.875)} + 1px),
        
        rgba(black, 0) unit(4.125), black unit(4.125), black calc(#{unit(4.125)} + 1px), rgba(black, 0) calc(#{unit(4.125)} + 1px),
        rgba(black, 0) unit(4.375), black unit(4.375), black calc(#{unit(4.375)} + 1px), rgba(black, 0) calc(#{unit(4.375)} + 1px),
        rgba(black, 0) unit(4.625), black unit(4.625), black calc(#{unit(4.625)} + 1px), rgba(black, 0) calc(#{unit(4.625)} + 1px),
        rgba(black, 0) unit(4.875), black unit(4.875), black calc(#{unit(4.875)} + 1px), rgba(black, 0) calc(#{unit(4.875)} + 1px),
        
        rgba(black, 0) unit(5.125), black unit(5.125), black calc(#{unit(5.125)} + 1px), rgba(black, 0) calc(#{unit(5.125)} + 1px),
        rgba(black, 0) unit(5.375), black unit(5.375), black calc(#{unit(5.375)} + 1px), rgba(black, 0) calc(#{unit(5.375)} + 1px),
        rgba(black, 0) unit(5.625), black unit(5.625), black calc(#{unit(5.625)} + 1px), rgba(black, 0) calc(#{unit(5.625)} + 1px),
        rgba(black, 0) unit(5.875), black unit(5.875), black calc(#{unit(5.875)} + 1px), rgba(black, 0) calc(#{unit(5.875)} + 1px)
      ) no-repeat center left,
      white
    ;
  }
  
  .ruler::before,
  .ruler::after {
    display: none;
  }
}
            
          
!
999px
Loading ..................

Console