我需要这些键上的container..as你可以看到,他们是浮动到左侧内水平居中。那是因为我有一个float:left;属性在他们身上。
但是,当我删除浮动:左;属性和应用文本对齐:中心;到容器,这是发生了什么......
几乎居中,但并不完全。这是怎么回事?谢谢! :)
容器的CSS:
#navbar {
background: #303030;
width: 100%;
box-sizing: border-box;
text-align: center;
}
每个按钮的CSS:
a.button {
width: 16.3%;
background: #4d4d4d;
height: 50px;
display: inline-block;
text-decoration: none;
color: #fff;
text-align: center;
max-width: 250px;
padding-top: 12px;
box-sizing: border-box;
font-size: 145%;
transition-property: background, z-index, font-size, color;
transition-duration: 0.35s;
}
相关的HTML
<div id ="navbar">
<a href="https://www.answers.legal" class="button"><i class="fa fa-home"></i> HOME</a>
<a href="https://www.answers.legal/questions" class="button"><i class="fa fa-question"></i> Q&A</a>
<a href="https://www.answers.legal/forums" class="button"><i class="fa fa-comment"></i> FORUMS</a>
<a href="https://www.answers.legal/contact" class="button"><i class="fa fa-phone"></i> CONTACT</a>
<a href="https://www.answers.legal/support" class="button"><i class="fa fa-life-ring"></i> SUPPORT</a>
<a href="https://www.answers.legal/about" class="button"><i class="fa fa-info-circle"></i> ABOUT</a>
</div>
</div>
向我们展示更多您的代码。另外一个jsfiddle会帮助 – Andrew
进一步检查后,我注意到它在Firefox上完美显示,但没有集中在Chrome上......任何原因? –
顺便说一句,这个小故障只发生在小分辨率,所以如果你想复制它,在Chrome上放大400-500%或调整窗口大小。 –