Coordinate Width:Height Percentages for Images (Shrunk on Browser Resize)
I have created this "container" into which I place images (so that I can place text under them that shows up on hover).
Code:
.image-container {
position: relative;
float: right;
overflow: hidden;
width: 290px;
height: 290px;
margin: 0;
}
I am trying to figure out if there is any way of getting the width and the height to be equal percentages, instead of pixel amounts, so that when a browser resizes, they remain the same proportions, but get smaller.
Something like:
Code:
width: 25%;
height: width;
The width is the governing dimension, and that works, but the height cannot be the same percentage, because then it won't be a square (it actually doesn't work at all with the height, never mind the varying dimension). It works if I put the width as a percentage and leave the height in pixel amounts, but that's not what I want.
I tried "height:auto;" and that also didn't work.
Thanks!