I want to center a container div within another div, and the child divs of the container need to also be centered, but left-aligned with each other. The child divs are of variable and unpredictable width.
For example:
<div>
<div class="container">
<div class="child"><img />Text</div>
<div class="child"><img />Text Widest</div>
<div class="child"><img />T</div>
</div>
</div>
I found a solution that works in Firefox, but need a universal solution. I also considered using JavaScript to measure the images, text, and div's, but am confident that I'm just CSS ignorant and there is a simple, elegant solution. Here is what works just in Firefox:
.container {
width: -moz-max-content;
margin: 0px auto 0px auto;
border-style: solid;
}
.child {
border-style: solid;
margin: 0px auto 0px auto;
}