0
我正在爲Bootstrap爲我的網站設置響應式導航欄。除了一件事之外,我主要想到了它。在屏幕爲width < ~775px
的設備上,使按鈕垂直堆疊而不是水平堆疊,第一個按鈕向左延伸一點,與其餘按鈕錯開。這是什麼原因造成的,我該如何解決?Vertical Bootstrap導航欄按鈕未對齊
的jsfiddle:https://jsfiddle.net/w10cspvv/
HTML:
<div id="navbar">
<nav class="navbar navbar-default">
<div class="container-fluid">
<ul class="nav nav-pills nav-justified">
<li role="presentation" class="active navbutton">
<a href="/"><img class='squidanim' src='https://www.glowingsquid.com/images/squid.gif' /><span>Home</span></a>
</li>
<li role='presentation' class='active navbutton'>
<a href='/about.php'><img class='squidanim' src='https://www.glowingsquid.com/images/squid.gif' /><span>About</span></a>
</li>
<li role='presentation' class='active navbutton'>
<a href='/contact.php'><img class='squidanim' src='https://www.glowingsquid.com/images/squid.gif' /><span>Contact</span></a>
</li>
</ul>
</div>
</nav>
</div>
CSS:
body {
background-color: black;
font-size: 16pt;
margin-top: 2em;
}
#navbar {
border: .25em solid #00aeef;
background-color: #00aeef;
border-radius: 25px;
}
.navbar {
margin-bottom: 0em;
}
.navbar-default {
border-radius: 25px;
border-color: #00aeef;
background: #00aeef;
}
.main {
font-family: Ubuntu, Tahoma, Geneva, sans-serif;
margin-left: 6em;
margin-right: 6em;
text-align: center;
}
.nav-pills > li.active > a,
.nav-pills > li.active > a:focus,
.nav-pills > li.active > a:hover {
background-color: #7F00FF;
}
.squidanim {
display: none;
}
.navbutton:hover a > .squidanim {
display: block;
height: 50px;
position: absolute;
z-index: 100;
}
.navbutton {
padding-left: 2em;
padding-right: 2em;
}
.nav > li > a {
padding-top: 0;
padding-bottom: 0;
}
.nav > li > a > span {
padding-top: 10px;
padding-bottom: 10px;
}
@media (max-width: 978px) {
#navbar {
margin-left: 2em;
margin-right: 2em;
}
.main {
margin-left: 1em;
margin-right: 1em;
}
.navbutton {
padding-left: 0;
padding-right: 0;
}
}
我在CSS中經驗不足,能否請您在答案中解釋li + li的含義,以及爲什麼它隻影響第一個?謝謝。 –
我現在明白 - 它會影響一切,但第一個。公認。謝謝! –