我有一个包含内联块li的导航。每个li包含两个块跨度元素,因此它在翻转时动画。我的问题是li导航的中心对齐和间距。我不想给li标签一个最小宽度。任何人都可以帮忙吗?
HTML:
<div id="nav">
<ul>
<li class="button">
<a href="#">
<span class="top">Home</span>
<span class="bottom">Home</span>
</a>
</li>
<li class="button">
<a href="#">
<span class="top">About</span>
<span class="bottom">About</span>
</a>
</li>
<li class="button">
<a href="#">
<span class="top">Equine</span>
<span class="bottom">Equine</span>
</a>
</li>
<li class="button">
<a href="#">
<span class="top">Canine</span>
<span class="bottom">Canine</span>
</a>
</li>
<li class="button">
<a href="#">
<span class="top">Rates & Travel</span>
<span class="bottom">Rates & Travel</span>
</a>
</li>
<li class="button">
<a href="#">
<span class="top">Case Study & News</span>
<span class="bottom">Case Study & News</span>
</a>
</li>
</div> <!---nav---->
CSS:
#nav {
height: 25px;
border-top: 2px solid #FFFFFF;
border-bottom: 1px solid #C7C7C7;
padding: 10px 0px 5px 0px;
text-align: center;
}
#nav li{
height: 16px;
line-height: 15px;
overflow: hidden;
display: inline-block;
padding: 0px 25px 0px 25px;
position: relative;
}
li span.top {
color: #16528e;
top: -18px;
}
a:hover span {
top: 18px;
}
a:hover span.top {
top: 0;
}
li span {
display: block;
top: 0;
position: absolute;
-webkit-transition: top 0.3s, border 0.3s, color 0.35s;
-moz-transition: top 0.3s, border 0.3s, color 0.35s;
-ms-transition: top 0.3s, border 0.3s, color 0.35s;
-o-transition: top 0.3s, border 0.3s, color 0.35s;
transition: top 0.3s, border 0.3s, color 0.35s;
}
答案 0 :(得分:0)
position:absolute
正在li span
下创建此问题。您需要删除它,并通过将负top
应用于此css来获得效果。
For Instance,
li span {
display: block;
position: relative;
top: -15px;
-webkit-transition: top 0.3s, border 0.3s, color 0.35s;
-moz-transition: top 0.3s, border 0.3s, color 0.35s;
-ms-transition: top 0.3s, border 0.3s, color 0.35s;
-o-transition: top 0.3s, border 0.3s, color 0.35s;
transition: top 0.3s, border 0.3s, color 0.35s;
}
这是Solution。
希望这有助于。