我有一个使用 CSS 的下拉菜单,现在我被告知他们希望下拉菜单显示得慢一些。一切都很好,但到目前为止,当用户将鼠标悬停在导航上时,我无法减慢转换速度。使用纯 CSS 解决方案执行此操作的最佳方法是什么?
JSFiddle上的演示
HTML
<nav>
<ul>
<li><a href="#">Line 1</a></li>
<li><a href="#">Line 2</a>
<ul>
<li><a href="#">SubCat 1</a></li>
<li><a href="#">SubCat 2</a></li>
<li><a href="#">SubCat 3</a></li>
</ul>
</li>
<li><a href="#">Line 3</a>
<ul>
<li><a href="#">SubCat 4</a></li>
<li><a href="#">SubCat 5</a></li>
<li><a href="#">SubCat 6</a></li>
</ul>
</li>
<li><a href="#">Line 4</a>
<ul>
<li><a href="#">SubCat 7</a></li>
<li><a href="#">SubCat 8</a></li>
<li><a href="#">SubCat 9</a></li>
</ul>
</li>
</ul>
</nav>
CSS
nav {
background: url(../images/global/Navigation_Full.png) no-repeat;
width: 540px;
height: 54px;
margin: 0 auto;
color: #000;
}
nav ul{
display: inline-table;
list-style: none;
width: 100%;
position: relative;
border-top: 1px solid #FF9F69;
}
nav ul:after {
content: ""; clear: both; display: block;
}
nav ul ul {
display: none;
position: absolute;
width: auto;
top: 100%;
}
nav ul li:hover > ul {
display: block;
}
nav li:first-child {
border-left: none;
}
nav li {
text-align: center;
margin-left: 1px;
float: left;
height: 38px;
line-height: 40px;
padding: 0 10px;
}
nav li a {
padding: 10px 17px;
font-size: 0.813em;
text-decoration: none;
text-shadow: inherit;
color: #000;
}
nav li:hover {
box-shadow: 1px 1px 20px 1px rgba(64, 23, 0, 0.4) inset;
-webkit-transition-property:color, background;
-moz-transition-property:color, background;
-webkit-transition-duration: 0.2s;
-moz-transition-duration: 0.2s;
-webkit-transition-timing-function: linear, ease-in;
-moz-transition-timing-function: linear, ease-in;
}
nav ul ul {
background: rgb(125,56,16); /* Old browsers */
background: -moz-linear-gradient(top, rgba(125,56,16,1) 0%, rgba(233,103,31,1) 30px, rgba(233,103,31,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(125,56,16,1)), color-stop(30px,rgba(233,103,31,1)), color-stop(100%,rgba(233,103,31,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(125,56,16,1) 0%,rgba(233,103,31,1) 30px,rgba(233,103,31,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(125,56,16,1) 0%,rgba(233,103,31,1) 30px,rgba(233,103,31,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(125,56,16,1) 0%,rgba(233,103,31,1) 30px,rgba(233,103,31,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(125,56,16,1) 0%,rgba(233,103,31,1) 30px,rgba(233,103,31,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#7d3810', endColorstr='#e9671f',GradientType=0 ); /* IE6-9 */
border-radius: 0px; padding: 0;
border-top: none;
z-index: 1;
}
nav ul ul li {
float: inherit;
position: relative;
border-left: none;
border-right: none;
text-align: left;
font-size: 1em;
font-weight: lighter;
}
nav ul ul li a {
color: #fff;
}
nav ul ul li a:hover {
color: #000;
}
nav ul ul ul {
position: absolute; left: 100%; top:0;
}