As you will see, I have a div
(#innerPageWrapper
) that wraps around the divs that contain the content. #innerPageWrapper
also does act vis
Try setting width and height of the parent element to auto. Simplified example:
http://jsfiddle.net/kimgysen/8nWDE/
#innerPageWrapper {
width:auto;
height:auto;
background:red;
}
#innerPageWrapper p{
width: 100px;
height: auto;
margin: 10px auto;
background: yellow;
}
Edit:
Check this fiddle for a more advanced example, including horizontal and vertical center: http://jsfiddle.net/kimgysen/8nWDE/1/
The parent element will dynamically adapt to the bounds of the child elements.
You can also set dynamic width and height on child elements.
.outerDiv{
display: table-cell;
background-color: yellow;
width: auto;
height: auto;
vertical-align: middle;
text-align: center;
}
.innerDiv{
display: inline-block;
background-color: red;
width: 100px;
height: 100px;
margin: 20px;
}