Is it possible to make a "full-height" (height : 100%) div with fixed aspect ratio?
Asked
Active
Viewed 79 times
1 Answers
2
Yes there are many ways to accomplish this, an easy one is to set both the width and height of a div relative to the viewport height using viewport units (VH).
div {
width:40vh;
height:100vh;
}
Another simple solution is to use a wrapper div with percentage padding as seen in this solution.

Community
- 1
- 1

Dylan Stark
- 2,325
- 17
- 24
-
Thank you. It's all I need :) padding-bottom not useful for me because it depend of the width. I need depending on height. – Dmitry A. Feb 08 '17 at 23:12
-
@DmitryA. you are welcome! I believe you could also do the padding method with padding-right or padding-left to set the width relative to the height. – Dylan Stark Feb 09 '17 at 00:21