<body>
<div id="div01"></div>
<div id="div02"></div>
<img id="img01" src="...">
</body>
css
body{
width:90%;
margin:0 auto;
background-color:gold;
}
div01
, div02
and img01
are 100px
, 200px
and 300px
width, respectively.
The width of body's children is dynamically changed.
How can I set elastic width of the body, according to largest child ? Without using javascript, just pure css.
For example, if img01
becomes 250px
body
should be 250px
. If div01
becomes 400px
body
should be 400px
. And still staying horizontally centered.