How to align a div in the center of a HTML page?
I've to align some text in the center of the page wit开发者_开发技巧h div tag.
div#foo { text-align:center; }
to align the text within the div or
div#foo { width:100px; margin:0 auto; }
to make the div 100px width and horizontally center it.
You could set the style of the div to be:
<div style="width: 250px; margin-left:auto; margin-right:auto;">TEXT</div>
You can also place that style in a CSS class and set the class of the div to whatever you named it.
EDIT: If you include a width for the div, it centers...
You can try <div align="center">...</div>
Simply use the following styling:
div {margin:0 auto;}
精彩评论