Home › Forums › CSS › [Solved] Anchor and image inside of div › Reply To: [Solved] Anchor and image inside of div
inline-block are treated (sort of) as though they are text…so you can center them with
text-align:center. It’s a little more complex than that but that’s essentially it.
Block level items are just that, big honking blocks that ignore small instructions like
text-align…they have their own requirements and need to be put in their place by using
margin to move them around but their default alignment is left (generally).
Also, if you don’t set a width on block level item it’s default is to be 100% width of it’s parent.
If you give it a width, it sits right where it is (left) until you give it some margin.
Now it so happens that if you set
margin:auto to a block item it works out the amount of space it needs, splits it down the middle and applies it
automagically to left and right…boom…centered.
I recommend this site LearnLayout.com as well as some of Chris’ videos right here on CSS-Tricks.