I have a div <div class="arrow-up">
that defines a triangle using CSS.
Here’s an example :
.arrow-down {
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-top: 20px solid #f00;
}
<div class="arrow-down"></div>
I’m trying to make the triangle size responsive when the window is resized. I tried changing the boder from px
to vh
but it didn’t change anything.
2
Answers
Many responsive elements are sized based on the horizontal width of the viewport (using
vw
units). Using20vw
instead of20px
should make it responsive to resizing the viewport width.References:
https://www.w3schools.com/cssref/css_units.php
https://www.w3schools.com/cssref/tryit.php?filename=trycss_unit_vw