我的淡出效果不正常

时间:2017-10-08 16:44:02

标签: html css css3

请帮我查一下我的代码。我的淡出有一个问题,有一个白色的盒子淡出而不是我的下拉菜单。我不知道我的CSS有什么问题。 我试过搜索在线信息,但似乎没有帮助。谢谢! 我的复选框代码是:

ul {font-family: Arial, Verdana;
  font-size: 17px;
  margin: 0;
  padding: 0;
  list-style: none;}

.dropdown{padding-top: 40px;}

ul li{float:left;
  display:inline;
  position:relative;
  padding:0px;
  background-color:white;
  text-decoration: none;}
  
li ul {/*display:none;*/position:absolute;
padding:10px;
margin:0;
visibility:hidden; 
opacity:0; 
transition-property: opacity,visibility;
transition-duration: 0.8s,0s;
transition-delay: 0s, .4s;}

ul li a {display: block; 
text-decoration: none;
color:white; 
border-top: 1px solid #ffffff;
padding: 5px 15px 5px 15px;
margin-left: 1px; 
white-space:nowrap;}
ul li a:hover { background-color: rgba(0,173,239,0.8);}
li:hover ul {  display: block; position: absolute; }
li:hover li { float: none;font-size: 11px; } 
li:hover a { background-color: rgba(0,173,239,0.8); }
li:hover li a:hover { background-color: rgba(0,173,239,0.8);
color:black; }
nav ul li:hover ul{visibility:visible; opacity: 1;}
#rectangle{
  width:600px;
  height:100px;
  background:blue;
}
<nav class="dropdown" >
  <ul>
  	<li><a href="" style="color:black">HOME</a></li> 
  	<li><a href="" style="color:black">ABOUT</a> 
  	  <ul>
  		<li><a href="">The Team</a></li>
  		<li><a href="">History</a></li> 
  		<li><a href="">Vision</a></li> 
  	  </ul> 
  	</li> 
  	<li><a href="" style="color:black">SERVICES</a> 
  	  <ul> 
  		<li><a href="">1</a></li> 
  		<li><a href="">2</a></li> 
  		<li><a href="">3</a></li> 
  		<li><a href="">4</a></li> 
  		<li><a href="">5</a></li> 
  	  </ul> 
  	</li>
  	<li><a href="" style="color:black">BOOK NOW</a> 
  	  <ul> 
  		<li><a href="">Online</a></li> 
  		<li><a href="">Right Here</a></li> 
  		<li><a href="">Somewhere Else</a></li> 
  	  </ul> 
  	</li> 
  	<li><a href="" style="color:black">CONTACT US</a> 
  	  <ul> 
  		<li><a href="">Online</a></li> 
  		<li><a href="">Right Here</a></li> 
  		<li><a href="">Somewhere Else</a></li> 
  	  </ul> 
  	</li> 
  	<li><a href="" style="color:black">CAREERS</a> 
  	  <ul> 
  		<li><a href="">Online</a></li> 
  		<li><a href="">Right Here</a></li> 
  		<li><a href="">Somewhere Else</a></li> 
  	  </ul> 
  	</li> 
  	<li><a href="" style="color:black">FAQ</a> 
  	  <ul> 
  		<li><a href="">Online</a></li> 
  		<li><a href="">Right Here</a></li> 
  		<li><a href="">Somewhere Else</a></li> 
  	  </ul> 
  	</li> 
  </ul>   
</nav>
<div id="rectangle"></div>

我的jsfiddle.net代码是:   [1]: https://jsfiddle.net/rnqajxtr/

1 个答案:

答案 0 :(得分:0)

我将transition-property: opacity, visibility;的{​​{1}}更改为li ul。所以现在CSS看起来像这样:

transition-property: opacity;

它看起来像你想要的那样:https://jsfiddle.net/rnqajxtr/2/