0

我有一个包含内联块 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;
}
4

1 回答 1

0

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;
}

这是解决方案

希望这可以帮助。

于 2013-05-23T11:35:05.290 回答