How do I align a div in CSS?
I have a box that I made in CSS and I want it to be aligned to the center. Unfortunately I have looked all over and cannot find an answer that works.
HTML:
<div id="top_bar">
<div class="inner">
</div>
</div>
CSS:
#top_bar {
vertical-align:text-top;
width: 90%;
/*padding: 10px;*/
border: 3px solid gray;
/*margin: auto;
margin-left: auto;
margin-right: auto;*/
position: fixed;
bottom: 0px;
}
#top_bar .inner {
padding:10px;
}
body { margin-left:0px; }
删除position:fixed
,请参阅此问题以获取更多信息
#top_bar{
margin:0 auto;
/* Others .... */
}
也许试试在内部div上放置margin:auto
链接地址: http://www.djcxy.com/p/75814.html上一篇: div不在边缘0自动中间?
下一篇: 如何对齐CSS中的div?