我正在尝试将标题 > 部分居中。它适用于chrome和opera,但firefox推到左侧。我创建了一个名为and.body
的类。它无法在 firefox 上识别(我使用的是 firefox 18)。width: 960px
margin: 0 auto
margin: 0 auto
我已经尝试将display
值设置inline-block
为.body
类。它确实居中,但它推nav
到底部(适用于所有浏览器)。
这就是我想要做的
HTML
<header id="header">
<section class="body box">
<section class="flex1">
<a>MyWebsiteName</a>
</section>
<nav class="nav-list flex1">
<ul>
<li>
<a href="">Login</a>
</li>
<li><a href="">Register</a></li>
<li><a href="">Help</a></li>
</ul>
</nav>
</section>
CSS
.box {
display: -webkit-box;
display: -moz-box;
display: -o-box;
display: box;
-webkit-flex-direction: row;
-mox-flex-direction: row;
flex-direction: row;
-webkit-box-align: center;
-moz-box-align: center;
-o-box-align: center;
box-align: center;
}
.flex1 {
-webkit-box-flex: 1;
-moz-box-flex: 1;
-o-box-flex: 1;
box-flex: 1;
}
.body {
clear: both;
width: 960px;
margin: 0 auto;
}
header {
background: #0C2C52;
box-shadow: 0 0 .2em .1em rgb(78, 76, 76);
-webkit-box-shadow: 0 0 .2em .1em rgb(78, 76, 76);
-moz-box-shadow: 0 0 .2em .1em rgb(78, 76, 76);
margin-bottom: 1em;
padding: 1em 0;
}
header > section {
height: inherit;
}
#header section.flex1 {
display: inline-block;
}
.nav-list {}
.nav-list > ul {
float: right;
}