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.

            
              <div class="demo">

  <div class="demo__content">

    <svg class="svg">

      <symbol id="s-mask">
        <rect
            width="100%" height="100%"
            fill="#555"></rect>
        <g stroke="gray" stroke-width="12" fill="white">
          <circle r="30%" cx="50%" cy="50%"></circle>
        </g>
      </symbol>

      <mask id="mask"
          x="0" y="0">
        <use xlink:href="#s-mask"></use>
      </mask>

      <pattern id="pattern"
            viewBox="0 0 470 400"
        width="470" height="400" patternUnits="userSpaceOnUse">
        <path d="M77,0 L234,0 L155.5,400 L77,0 Z" fill="#FF9F00"></path>
          <polygon fill="#EE2A42" points="77.5 0 156 400 -1 400 "></polygon>
          <path d="M-79,0 L78,0 L-0.5,400 L-79,0 Z" fill="#A506CD"></path>
          <path d="M233,0 L390,0 L311.5,400 L233,0 Z" fill="#7ED321"></path>
          <polygon fill="#F8E81C" points="233.5 0 312 400 155 400 "></polygon>
          <polygon fill="#049BD8" points="389.5 0 468 400 311 400 "></polygon>
          <path d="M389,0 L546,0 L467.5,400 L389,0 Z" fill="#A506CD"></path>
      </pattern>

      <symbol id="s-coords">
        <g stroke-dasharray="10 5">
          <line x1="50%" y1="0" x2="50%" y2="100%" />
          <line y1="50%" x1="0" y2="50%" x2="100%" />
        </g>
      </symbol>

      <use xlink:href="#s-coords" stroke="#333"></use>

      <g>
        <rect width="80%" height="90%"
            fill="steelblue" fill-opacity=".3"
            stroke="steelblue" stroke-width="3"></rect>

        <rect mask="url(#mask)"
            width="80%" height="90%"
            fill="url(#pattern)"></rect>

        <use xlink:href="#s-coords" width="80%" height="90%" stroke="steelblue"></use>
      </g>

    </svg>
  </div>

</div>

            
          
!
            
              
/* Vars & Mixins
------------------------------ */

$svgW: 500px;
$svgH: 300px;

$controlH: 40px;

$space: 10px;

$colors: purple, crimson, orangered, yellowgreen, skyblue, steelblue, olive, teal, indigo;

@mixin outline( $counter: 1 ) {
  outline: 2px solid nth( $colors, $counter );
}

@mixin valnMid {
  &:before {
    content: ' ';
    display: inline-block;
    height: 100%;
    vertical-align: middle;
  }
}

/* Base
------------------------------ */

HTML, BODY {
  height: 100%;
}

BODY {
  background: #FFF;  
  background-image:
    linear-gradient( #EEE 1px, transparent 2px),
    linear-gradient( to right, #EEE 1px, transparent 2px);
  background-size: 1em 1em;

}

/* Layout
------------------------------ */

.demo {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  white-space: nowrap;
  font: 16px/1.4 Arial, sans-serif;
}

.demo__content {
  position: relative;
  width: $svgW;
  height: $svgH;

  &--svg-only {
    /* default */
  }

  &--left-range {
    width: $svgW + $controlH + $space;
  }

  &--top-range {
    height: $svgH + $controlH + $space;
  }

  &--both-ranges {
    width: $svgW + $controlH + $space;
    height: $svgH + $controlH + $space;
  }
}

/* SVG
------------------------------ */

.svg {
  position: absolute;
  right: 0;
  bottom: 0;
  width: $svgW;
  height: $svgH;
  box-sizing: border-box;
  border: 2px solid #333;
}

/* Controls
------------------------------ */

.controls {

  &__title {
    display: inline-block;
    vertical-align: middle;
    margin-top: 0;
    margin-bottom: 0;
    font-weight: bold;
    font-size: 100%;  
  }
}

  .controls--buttons {
    @include valnMid;
    height: $controlH;
    margin-bottom: $space;
    font-size: 1rem;
  }

/* Buttons
------------------------------ */

.button {
  margin-left: .5rem;
  padding: .3rem .5rem;
  vertical-align: middle;
  border: 0;
  background: #BBB;
  cursor: pointer;
  font-size: 1rem;
  text-shadow: 0 0 1px rgba(0, 0, 0, .75);
  color: #FFF;

  &--current {
    background: crimson;
  }
}

/* Ranges
------------------------------ */

.controls--ranges {
  position: absolute;
  width: 100%;
}
  .range {
    position: absolute;
    height: $controlH;
    text-align: center;

    &--hor {
      right: 0;
      width: $svgW;
    }

    &--vert {
      top: $controlH + $space;
      width: $svgH;
      transform-origin: 0 0;
      transform: rotate(-90deg) translateX(-100%);
    }

      &--vert .range__input {
        transform: rotate(180deg);
      }
  }

  .range__input {
    width: 100%;
    margin: auto;
    cursor: pointer;
  }

            
          
!
            
              // Required
// 1. tinyLib:
// https://codepen.io/yoksel/pen/KMgMvw
// 2. demosBuilder: 
// https://codepen.io/yoksel/pen/JKRKyy

console.clear();

"use strict";

var $ = tinyLib;

var config = {
  demoContentLayout: 'both-ranges',
  targetElem: $.get( '#mask' ),

  inputs: {
    ranges: {
      units: '%',

      attrs: {
        type: 'range',
        min:0,
        max: 100,
        step:1,
        value: 50,
      },

      list: [
        {
          id: 'hor',
          valName: 'width'
        },
        {
          id: 'vert',
          valName: 'height'
        }
      ]
    },

    buttons: {
      prop: 'maskUnits',
      list: [ 'objectBoundingBox', 'userSpaceOnUse' ],
      default: 'userSpaceOnUse',
      current: null,
      currentClass: 'button--current'
    }
  }
};

demosBuilder.create();
            
          
!
999px
Loading ..................

Console