I’ve been having trouble finding this one.
I have a div that is centered in the body margin: 0 auto;.
It contains multiple divs. I want it to expand to the width of it’s widest child width: auto;
The problem is I want to have one of the child div’s aligned on the right, however this expands my parent to 100%. How would I accomplish this without a fixed width for the parent?
You could do what you are after by setting the wrapper div to
inline-block, and settingtext-align: centeron its parent (instead of usingmargin: 0 auto;). Here is an example: http://jsfiddle.net/joshnh/6Ake5/Here is the HTML:
And the CSS: