I need a <div>
with a height
in percent and a width
so that it is a square. So the width
has to refer to the height
.
CSS:
#square {
height: 100%;
width: "100% of height of this div";
}
HTML:
<div id="square"></div>
I've seen a solution with the padding-top
property (example), but it only works with a given height
. Another way is a JavaScript/jQuery solution like this, but I would prefer a CSS only solution.
Is there a nice way of doing this (without a blank square <img>
or something)? Maybe equal to padding-top
? I've tried padding-right
already but it does not work.