0

我想修复这个小提琴,你可以看到它不能正常工作。我想水平制作这个导航,垂直制作子菜单,水平制作子菜单的子菜单,但问题是我也使用了过渡,但它不能正常工作。第一个子菜单不平稳下降,但顺利推出,第三个菜单不像平稳滚动和推出。我想解决这个问题,我想帮助解决这个问题。这是小提琴,所有代码都包括这个。 http://jsfiddle.net/hsn0/nQneb/

css

#nav {
height: auto;
width: auto;
}
#nav ul {
margin: 0px;
padding: 0px;
list-style-type: none;
}
#nav ul li {
float: left;
position: relative;
}
#nav ul li a {
line-height: 30px;
text-decoration: none;
text-align: center;
display: block;
width: 100px;
height: 30px;
border: thin solid #999;
color: #FFF;
background-color: #0CF;
-webkit-transition: all 1s;
-moz-transition: all 1s;
-ms-transition: all 1s;
-o-transition: all 1s;
transition: all 1s;
 }
 #nav ul li a:hover {
background-color: #0C3;
 }
 #nav ul li ul {
position: absolute;
visibility: hidden;
-webkit-transition: all 1s linear 0s;
-moz-transition: all 1s linear 0s;
-ms-transition: all 1s linear 0s;
-o-transition: all 1s linear 0s;
transition: all 1s linear 0s;
overflow: hidden;
height: 0px;
 }
 #nav ul li:hover ul {
height: 100px;
visibility: visible;
overflow: visible;
 }
 #nav ul li ul li {
-ms-transition: all 1s;
-o-transition: all 1s;
 }
 #nav ul li ul li a {
background-color: #666;
-webkit-transition: all 1s;
-moz-transition: all 1s;
-ms-transition: all 1s;
-o-transition: all 1s;
transition: all 1s;
 }
 #nav ul li ul li a:hover {
background-color: #C30;
 }
 #nav ul li ul li ul {
position: absolute;
left: 102px;
top: 0px;
display: none;
-webkit-transition: all 1s ease 0s;
-moz-transition: all 1s ease 0s;
-ms-transition: all 1s ease 0s;
-o-transition: all 1s ease 0s;
transition: all 1s ease 0s;
overflow: hidden;
visibility: hidden;
width: 0px;
 }
 #nav ul li ul li ul li {
float: left;
position: relative;
 }
 #nav ul li ul li:hover ul {
width: 104px;
display: block;
/* [disabled]overflow: visible; */
visibility: visible;
 }

 **html**

<nav id="nav">
 <ul>
   <li><a href="#">Item1</a>
 <ul>
   <li><a href="#">Sub1</a></li>
  <li><a href="#">Sub1</a></li>
   <li><a href="#">Sub1</a>
     <ul>
 <li><a href="#">Sub2</a></li>
        <li><a href="#">Sub2</a></li>
        <li><a href="#">Sub2</a></li>
     </ul>

    </li>
   </ul>
  </li>
 </ul>
</nav>
4

2 回答 2

0

请查看此演示

我觉得主要问题是由于可见性和溢出,我们可以过渡不透明度和高度。

我为此使用了很少的菜单部分......我尝试了高度,尽管它也适用于所有人。

#nav ul li ul {
    position: absolute; 
    -webkit-transition: height  1s linear 0s;
    -moz-transition: height  1s linear 0s;
    -ms-transition: height  1s linear 0s;
    -o-transition: height  1s linear 0s;
    transition: height 1s linear 0s;    
    height: 0px;
    overflow:hidden;
}
#nav ul li:hover ul {
    height: 100px;

        -webkit-transition: height 1s linear 0s;
    -moz-transition: height 1s linear 0s;
    -ms-transition: height 1s linear 0s;
    -o-transition: height 1s linear 0s;
    transition: height 1s linear 0s;
}
于 2013-07-30T18:10:19.853 回答
0

我希望,下面的CSS会解决你的问题

         #nav {
            height: auto;
            width: auto;
        }
        #nav ul {
            margin: 0px;
            padding: 0px;
            list-style-type: none;
        }
        #nav ul li {
            float: left;
            position: relative;
        }
        #nav ul li a {
            line-height: 30px;
            text-decoration: none;
            text-align: center;
            display: block;
            width: 100px;
            height: 30px;
            border: thin solid #999;
            color: #FFF;
            background-color: #0CF;
            -webkit-transition: all 0.3s ease-out;
            -moz-transition: all 0.3s ease-out;
            -o-transition: all 0.3s ease-out;
            /*transition: all 0.3s ease-out;*/
            transition:display 0s linear 0.5s,opacity 0.5s linear;
        }
        #nav ul li a:hover {
            background-color: #0C3;
        }
        #nav ul li ul {
            position: absolute;
            height:0;
            visibility:hidden;
            opacity:0;
            -webkit-transition: all 1s ease-out;
            -moz-transition: all 1s ease-out;
            -o-transition: all 1s ease-out;
            transition: all 1s ease-out;
        }
        #nav ul li:hover ul {
            opacity:1;
            visibility:visible; 
            overflow: visible;
        }

        #nav ul li ul li a {
            background-color: #666;
            -webkit-transition: all 0.3s ease-out;
            -moz-transition: all 0.3s ease-out;
            -o-transition: all 0.3s ease-out;
            transition: all 0.3s ease-out;
        }
        #nav ul li ul li a:hover {
            background-color: #C30;
        }
        #nav ul li ul li ul {
            position: absolute;
            left: 102px;
            top: 0px;
            visibility:hidden !important;
            opacity:0 !important;
            -webkit-transition: all 1s ease-out;
            -moz-transition: all 1s ease-out;
            -o-transition: all 1s ease-out;
            transition: all 1s ease-out;
            overflow: hidden;
        }
        #nav ul li ul li:hover .last {
            opacity:1 !important;
            visibility:visible !important;
            overflow: visible;
        }
        #nav ul li ul li .last li{
            float: left;
            position: relative;
        }
        #navul li ul li .last li a {
            line-height: 30px;
            text-decoration: none;
            text-align: center;
            display: block;
            width: 100px;
            height: 30px;
            border: thin solid #999;
            color: #FFF;
            background-color: #0CF;
            -webkit-transition: all 0.3s ease-out;
            -moz-transition: all 0.3s ease-out;
            -ms-transition: all 0.3s ease-out;
            -o-transition: all 0.3s ease-out;
            transition: all 0.3s ease-out;
        }

HTML

        <nav id="nav">
          <ul>
            <li><a href="#">Item1</a>
            <ul>
              <li><a href="#">Sub1</a></li>
              <li><a href="#">Sub1</a></li>
                <li><a href="#">Sub1</a>
                 <ul class="last">
                    <li><a href="#">Sub2</a></li>
                    <li><a href="#">Sub2</a></li>
                    <li><a href="#">Sub2</a></li>
                 </ul>

                </li>
            </ul>
            </li>
          </ul>

        </nav>
于 2013-08-06T12:13:11.993 回答