11 ms·
Margin auto does work, and it'll work for most people when they need it to work.
by SteveP1961 13y ago
Margin auto does work, and it'll work for most people when they need it to work.
- STRML 13y agoWhat they're getting at is that the vertical aspect of margin:auto (that is, margin: 0 auto vs margin: auto) has absolutely no effect in your example. For your own credibility (since this purports to be a "complete" guide), this needs to be fixed and you need to add the table/table-cell method. I think it would be best to simply replace that example with what is essentially the last example, which is much more useful. This codepen[1] shows the markup within another div. This is by far my favorite centering method, although it requires a fixed or percentage height while table/table-cell does not. It also avoids some of the bizarre quirks of table/table-cell, so there are times when one or the other is the best method. [1] http://codepen.io/anon/pen/whHIL http://codepen.io/anon/pen/whHIL