我有一个包含行内块li的导航。每个li包含两个block span元素,因此它在翻转时显示动画。我的问题是与中心对齐和间距的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;
}
position:absolute
在li span
下创建此问题。你需要删除它,你会得到你的效果,通过应用负top
到这个css。
例如
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;
}
这就是解决方案。