0
我有含有欲自舉導航欄居中DIV中的錨標籤
的高度和圖像的寬度的div標籤內的中心是未知的,所以我想中心的圖像的錨其水平和垂直方向,而不必計算填充
<div class="navbar-header">
<a class="navbar-left" href="index.html"><span role="link" class="logo"></span></a>
</div>
.navbar-header{
width: 250px;
height: 60px;
float: left;
}
.navbar-left{
float: left!important;
}
.logo {
background-image: url(/image.png);
background-position: center;
background-size: 100%;
border: none;
display: block;
height: 51px;
width: 185px;
margin: 0;
text-indent: -9999px;
}
嘗試增加'的text-align:center'到導航欄頭 –
你已經嘗試過的答案在這裏:http://stackoverflow.com/questions/27037514/how-to-center-brand-image-in-navbar和這裏:http://stackoverflow.com/questions/23400234/centering-brand-logo-in-bootstrap -3-導航欄 – ZimSystem