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

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -