I need to scale the height of divs.
How it should work
- The divs should scale, keep current aspect ratio
- The width should be 100px always
- The height should scale in propotion to the 100px width
- I added some example width and height in the code
- Add more HTML + CSS if needed
Example
A div block is originally 300px x 600px. When fit the width of 100px it will be 100px x 200px.
The result
The result will be divs equally wide but they will be different height, some taller than others.
https://jsfiddle.net/80pk066L/5/
Notes
If it whould be an image it would contain aspect ratio when setting width to 100%, but this is not an image. It is a div.
HTML
<ul>
<li class="scale1"><div></div></li>
<li class="scale2"><div></div></li>
<li class="scale3"><div></div></li>
<li class="scale4"><div></div></li>
<li class="scale5"><div></div></li>
</ul>
CSS
ul {
width: 300px;
}
li {
float: left;
background: red;
margin: 10px;
list-style: none;
display: block;
height: 100px;
width: 100px;
/*REMOVE HEIGHT AND WIDTH HERE, JUST DECORATION
Width should always be 100px
Height should be whatever, can be larger than 100px
*/
}
.scale1 div {
width: 300px;
height: 500px;
}
.scale2 div {
width: 400px;
height: 400px;
}
.scale3 div {
width: 200px;
height: 300px;
}
.scale4 div {
width: 50px;
height: 60px;
}
.scale5 div {
width: 150px;
height: 75px;
}
liforms a 100px square, and has a childdivof a certain aspect ratio, and you want the childdivto fit in theli? - Marc Audetdiv" in your scale definitions - it is implied by the dot. I'm not sure what you mean by scale... if you want height of 200 and width of 100, why not set that? - steve klein