EN
CSS - what is difference between 100vw and 100%?
1 answers
2 points
I was analysing some source code and, I have noticed there was used 100vw
with width CSS property.
My question is:
Is 100vw
the same like 100%
?
If not, what is difference between 100vw
and 100%
?
1 answer
4 points
100vw
means 100% width of viewport width.
e.g.
xxxxxxxxxx
1
<body>
2
<div>
3
<div class="element" style="width: 100vh"></div>
4
</div>
5
</body>
100%
means 100% size of parent element size
It means:
- width when
width: 100%
style property is used, - height when
height: 100%
style property is used.
e.g.
xxxxxxxxxx
1
<body>
2
<div class="parent">
3
<div class="element" style="width: 100%"></div>
4
</div>
5
</body>
Viewport is a rectangular area that contains the part of the web page that is currently visible in web browser window.
See also
0 commentsShow commentsAdd comment