startv

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
via CSS Lint

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
via JS Hint

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Want a Run Button?

If active, the preview will update automatically when you change code.

HTML

            
                  <div class="col one">     
      This example showcases use of (fake) vw unit. While things like width were already easy to tie to width of viewport, other properties, such as padding or font size or border radius were not. You should be able to see a couple of boxes with text, which are supposed to change font size, border width, border radius, and padding in response to viewport width changes.
    </div>
    <div class="col two">
        This example showcases use of (fake) vw unit. While things like width were already easy to tie to width of viewport, other properties, such as padding or font size or border radius were not. You should be able to see a couple of boxes with text, which are supposed to change font size, border width, border radius, and padding in response to viewport width changes.
    </div>
    <div class="col three">
        This column does not use the viewport width scaling, and so does not change (except in width) when the window is resized or device is rotated.
    </div>

            
          
!

CSS

            
              html { position: relative; }
body { font-size: 12px; font-family: sans-serif; margin: 0; padding: 0;}


.col { float: left; width: 33.3%; box-sizing: border-box; }
.col.one { background: #CFF; }
.col.two { background: #FFC; }
.col.three { background: #FCF; font-size: 20px; padding: 50px; }

.one, .two {

  border: solid #666;
  border-width: 10px; border-width: 0.01rem; /*1vw*/
  border-radius: 30px; border-radius: 0.03rem; /*3vw*/
  font-size: 20px; font-size: 0.02rem; /*2vw*/
  padding: 20px; padding: 0.02rem; /*2vw*/
}

            
          
!

JS

            
              (function (doc, win) {
    var docEl = doc.documentElement,
        recalc = function () {
            var clientWidth = docEl.clientWidth;
            if (!clientWidth) return;

            docEl.style.fontSize = clientWidth + 'px';
            docEl.style.display = "none";
            docEl.clientWidth; // Force relayout - important to new Androids
            docEl.style.display = "";
        };

    // Abort if browser does not support addEventListener
    if (!doc.addEventListener) return;

    // Test rem support
    var div = doc.createElement('div');
    div.setAttribute('style', 'font-size: 1rem');

    // Abort if browser does not recognize rem
    if (div.style.fontSize != "1rem") return;

    win.addEventListener('resize', recalc, false);
    doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);
            
          
!
999px
Loading ..................

Console