I have a number of HTML elements with display: inline-block . They look like boxes. Here's a simplified example:
.box { display: inline-block; border: solid darkblue 1px; padding: 5px; margin-right: 1em; text-align: center; background-color: lightgoldenrodyellow; }
<div class="box">This<br>is<br>a<br>box</div> <div class="box">This<br>is<br>a<br>tall<br>box</div> <div class="box">This box is wider than it is tall<br>and therefore needs no adjustment</div>
I need each box to be at least wide , given the following restrictions:
- CSS only. No javascript
- The height and width of the drawers cannot be set explicitly (including min and max)
inline-block . A long row of boxes will need to be wrapped beautifully, automatically- The content inside each window should be centered.
I found a technique that would make an element at least as tall as wide, but rely on the fact that the percentage is the length for margin or padding relative to the width of the element. There seems to be no equivalent for creating a box that is at least as wide as tall.
Is it possible?
html css
Tim down
source share