123

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <h1>Element Queries</h1>
<h2>with <a href=http://github.com/tomhodgins/reprocss>reproCSS</a></h2>

<h3>Min-Width</h3>
<div id="minWidth">Min Width (drag to resize)</div>

<h3>Max-Width</h3>
<div id="maxWidth">Max Width (drag to resize)</div>

<h3>Min-Height</h3>
<div id="minHeight">Min Height (drag to resize)</div>

<h3>Max-Height</h3>
<div id="maxHeight">Max Height (drag to resize)</div>

<h3>Min-Characters</h3>
<div id="minCharacters" contenteditable>Min Characters (type in here)</div>

<h3>Min-Characters (on form inputs)</h3>
<input id="minCharactersForm" placeholder="Min Characters on form inputs">

<h3>Max-Characters</h3>
<div id="maxCharacters" contenteditable>Max Characters (type in here)</div>

<h3>Max-Characters (on form inputs)</h3>
<input id="maxCharactersForm" placeholder="Max Characters on form inputs">

<h3>Min-Children</h3>
<div id="minChildren">Min Children
</div>
<input type=button onclick="previousElementSibling.appendChild(document.createElement('div'));" value="Add Child">

<h3>Max-Children</h3>
<div id="maxChildren">Max Children
</div>
<input type=button onclick="previousElementSibling.appendChild(document.createElement('div'))" value="Add Child">

<h3>Min-Scroll-X</h3>
<div id="minScrollX">
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Totam distinctio, doloremque, iure magni neque sed natus eveniet, atque tempora aliquid dolores deleniti impedit amet doloribus voluptatibus vel dolorem sit qui.</p>
</div>

<h3>Max-Scroll-X</h3>
<div id="maxScrollX">
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Totam distinctio, doloremque, iure magni neque sed natus eveniet, atque tempora aliquid dolores deleniti impedit amet doloribus voluptatibus vel dolorem sit qui.</p>
</div>

<h3>Min-Scroll-Y</h3>
<div id="minScrollY">
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Totam distinctio, doloremque, iure magni neque sed natus eveniet, atque tempora aliquid dolores deleniti impedit amet doloribus voluptatibus vel dolorem sit qui.</p>
</div>

<h3>Max-Scroll-Y</h3>
<div id="maxScrollY">
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Totam distinctio, doloremque, iure magni neque sed natus eveniet, atque tempora aliquid dolores deleniti impedit amet doloribus voluptatibus vel dolorem sit qui.</p>
</div>

<h3>Min-Aspect-Ratio</h3>
<div id="minAspectRatio">(drag to resize)</div>

<h3>Max-Aspect-Ratio</h3>
<div id="maxAspectRatio">(drag to resize)</div>

<h3>Orientation</h3>
<div id="orientation"></div>

<style id=example process="resize input click mousemove touchmove">
  /* @element #minWidth and (min-width: 500px) {} */
  /* #minWidth[test="this.offsetWidth > 500"] */
  ${minWidth.offsetWidth > 500 && '#minWidth'} {
    background: violet;
  }

  /* @element #maxWidth and (max-width: 500px) {} */
  /* #maxWidth[test="this.offsetWidth < 500"] */
  ${maxWidth.offsetWidth < 500 && '#maxWidth'} {
    background: violet;
  }

  /* @element #minHeight and (min-height: 100px) {} */
  /* #minHeight[test="this.offsetHeight > 100"] */
  ${minHeight.offsetHeight > 100 && '#minHeight'} {
    background: violet;
  }

  /* @element #maxHeight and (max-height: 100px) {} */
  /* .max-height[test="this.offsetHeight < 100"] */
  ${maxHeight.offsetHeight < 100 && '#maxHeight'} {
    background: violet;
  }

  /* @element #minCharacters and (min-characters: 5) {} */
  /* #minCharacters[test="this.innerHTML.length > 5"] */
  ${minCharacters.innerHTML.length > 5 && '#minCharacters'} {
    background: violet;
  }

  /* @element #maxCharacters and (max-characters: 5) {} */
  /* #maxCharacters[test="this.innerHTML.length < 5"] */
  ${maxCharacters.innerHTML.length < 5 && '#maxCharacters'} {
    background: violet;
  }

  /* @element #minCharactersForm and (min-characters: 5) {} */
  /* #minCharactersForm[test="this.value.length > 5"] */
  ${minCharactersForm.value.length > 5 && '#minCharactersForm'} {
    background: violet;
  }

  /* @element #maxCharactersForm and (max-characters: 5) {} */
  /* #maxCharactersForm[test="this.value.length < 5"] */
  ${maxCharactersForm.value.length < 5 && '#maxCharactersForm'} {
    background: violet;
  }

  /* @element #minChildren and (min-children: 3) {} */
  /* #minChildren[test="this.children.length > 3"] */
  ${minChildren.children.length > 3 && '#minChildren'} {
    background: violet;
  }

  /* @element #maxChildren and (max-children: 3) {} */
  /* #maxChildren[test="this.children.length < 3"] */
  ${maxChildren.children.length < 3 && '#maxChildren'} {
    background: violet;
  }

  /* @element #minScrollX and (min-scroll-x: 100px) {} */
  /* #minScrollX[test="this.scrollLeft > 100"] */
  ${minScrollX.scrollLeft > 100 && '#minScrollX'} {
    background: violet;
  }

  /* @element #maxScrollX and (max-scroll-x: 100px) {} */
  /* #maxScrollX[test="this.scrollLeft < 100"] */
  ${maxScrollX.scrollLeft < 100 && '#maxScrollX'} {
    background: violet;
  }

  /* @element #minScrollY and (min-scroll-y: 50px) {} */
  /* #minScrollY[test="this.scrollTop > 50"] */
  ${minScrollY.scrollTop > 50 && '#minScrollY'} {
    background: violet;
  }

  /* @element #maxScrollY and (max-scroll-y: 50px) {} */
  /* #maxScrollY[test="this.scrollTop < 50"] */
  ${maxScrollY.scrollTop < 50 && '#maxScrollY'} {
    background: violet;
  }

  /* @element #minAspectRatio and (min-aspect-ratio: 1/1) {} */
  /* #minAspectRatio[test="this.offsetWidth/this.offsetHeight > 16/9"] */
  ${minAspectRatio.offsetWidth/minAspectRatio.offsetHeight > 16/9 && '#minAspectRatio'} {
    background: violet;
  }

  /* @element #maxAspectRatio and (max-aspect-y: 1/1) {} */
  /* #maxAspectRatio[test="this.offsetWidth/this.offsetHeight < 16/9"] */
  ${maxAspectRatio.offsetWidth/maxAspectRatio.offsetHeight < 16/9 && '#maxAspectRatio'} {
    background: violet;
  }

  /* @element #orientation and (orientation: portrait) {} */
  /* #orientation[test="this.offsetWidth < this.offsetHeight"] */
  ${orientation.offsetWidth < orientation.offsetHeight && '#orientation'} {
    background: orange;
  }

  /* @element #orientation and (orientation: square) {} */
  /* #orientation[test="this.offsetWidth == this.offsetHeight"] */
  ${orientation.offsetWidth == orientation.offsetHeight && '#orientation'} {
    background: darkturquoise;
  }

  /* @element #orientation and (orientation: landscape) {} */
  /* #orientation[test="this.offsetWidth > this.offsetHeight"] */
  ${orientation.offsetWidth > orientation.offsetHeight && '#orientation'} {
    background: greenyellow;
  }
</style>
            
          
!
            
              Array.from(document.querySelectorAll('[id*="Scroll"]'), tag => {
  tag.addEventListener('scroll', e => {
    reprocss.apply(example.getAttribute('data-reprocss'))
  })
})
            
          
!
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.

Console