html - Viewport vs Percentage -
i using percentage when creating responsive designs , haven't used viewports yet. know when use viewport , when use percentage because looks similar me.
fiddle example
html
<div class="percent">hello world</div> <br/> <div class="viewport">hello world</div>
css
div.percent{ width:100%; background-color:#09c; color:white; } div.viewport{ width:100vw; background-color:#09c; color:white; }
percentages based on parent containers, viewport units consistent viewport.
if have percentage on direct child of body
they're off, since body has default margin.
Comments
Post a Comment