I'm trying to create a div
and keeping its aspect ratio to 16 : 9 using css. I made a google search, and quickly found this: How to maintain the aspect ratio. So I tried doing it myself, but came upon a problem. When I add text inside, the ratio changes, and isn't 16 : 9 ratio anymore.
When you remove all the li's
, then the ratio is correct. How can I keep the aspect ratio even when adding text inside?
Code Snippet:
div {
width: 70%;
}
ul {
padding-bottom: 56.25%;
background: green;
}
<div>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>