I want some divs to get their width from their content. Display:inline-block does this, but I also want the divs to be under each other, not next to each other as floated.
Using float:left instead of inline-block does this, but I want the divs to be center aligned, not left aligned. How can I do this?
on the parent div put white-space: pre-line; on the child divs add clear : both
http://jsfiddle.net/judsonmusic/8HCWp/
Working jsFiddle Demo
Consider the following markup:
Because you want to
align
your elements, you must useinline
, then we will break them with:after
:html is
and style sheet is
check demo at http://jsfiddle.net/xupHN/
As mentioned in this thread, there's also a flex solution to this problem: