我正在水平居中一个div。我有下面的代码来垂直和水平居中我的div在身体标记,但似乎只是垂直的作品。我怎样才能让水平片能够工作。提前致谢。CSS如何水平居中一个div
body
{
background-color: #081418;
font-size: .75em;
font-family: Verdana, Helvetica, Sans-Serif;
margin: 0;
padding: 0;
color: #696969;
text-align: center;
}
.OuterRim
{
border:5px solid #99D7C0;
height: 97%;
width: 85%;
/*center aligning*/
display: block;
text-align: left;
margin: 0px auto;
}
可能的重复:http://stackoverflow.com/questions/618097/how-do-you-easily-horizontally-center-a-div-using-css – Boaz 2013-02-11 21:39:34
没有。那个链接根本没有帮助。如果仔细观察,您会看到我已经应用了该示例中的答案,但仍未获得理想的结果。 – Kobojunkie 2013-02-11 21:48:05
看到我对此的回答[输入链接描述](http://stackoverflow.com/questions/618097/how-do-you-easily-horizontally-center-a-div-using-css/43509117#43509117) – 2017-04-20 02:37:07