Sunday, May 24, 2015

Stupid mirror


Sometimes it is not the text that needs to be centered, but the block as a whole. Or, phrased differently: we want the left and right margin to be equal. The way to do that is to set the margins to 'auto'. This is normally used with a block of fixed width, because if the block itself is flexible, it will simply take up all the available width. Here is an example:

This is also the way to center an image: make it into block of its own and apply the margin properties to it. For example:

0 comments:

Post a Comment