User Tools

Site Tools


css

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

css [2017/03/15 16:45] (current)
shawn created
Line 1: Line 1:
 +====== Center a block element ======
  
 +''​text-align''​ only centers the text inside the block. To center an entire
 +block element, we must make it smaller than the parent (otherwise,
 +what's the point?) then tell the browser to adjust the left and right
 +margins accordingly.
 +
 +<code css>
 +div.center {
 + width: 80%;
 + margin-left:​ auto;
 + margin-right:​ auto;
 +/* -or-
 + margin: 0 auto;
 +*/
 +}
 +</​code>​
css.txt ยท Last modified: 2017/03/15 16:45 by shawn