我在我的网站上有一个特定的情况。我试图让导航器下拉框重叠它下面的元素,但是它会在打开时将它们向下移动。使用“样本网站”选项卡可以看到问题here (http://beta.wreckmodz.com/)。以下是我的导航栏HTML。HTML&jQuery - 需要重叠重叠元素
<nav>
<a href="/index"><item>Home</item></a>
<a href="/request"><item>Request Service</item></a>
<a href="/contact"><item>Contact Us</item></a>
<a href="/about"><item>About Us</item></a>
<item class="dropdown">Sample Sites
<li>
<a href="/tipcalc/index">
<item>TipCalc</item>
</a>
</li>
<li>
<a href="/example-1/index">
<item>Sample #1</item>
</a>
</li>
<li>
<a href="http://ucpcs.wreckmodz.com/">
<item>Sample #2</item>
</a>
</li>
</item>
<a href="/shop"><item>Shop</item></a>
</nav>
这里是我的CSS:
nav {
display: block;
background: rgba(255,255,255,0.9);
box-shadow: 1px 1px 5px #000000;
height: 38px;
margin-bottom: 1%;
overflow: visible;
}
item {
display: block;
border-right: 1px dotted #000000;
float: left;
width: auto;
padding: 3px;
padding-left: 10px;
padding-right: 10px;
color: #0099ff;
line-height: 200%;
}
item:hover {
background: #000000;
color: #ffffff;
}
li {
display: none;
list-style: none;
}
a:link, a:visited {
color: #0099ff;
text-decoration: none;
}
a:hover {
color: #ffffff;
}
这里是我的jQuery/Javascript代码:
$(document).ready(function(){
$('item.dropdown').mouseenter(function(){
$('li').fadeIn(100);
});
$('item.dropdown').mouseleave(function(){
$('li').fadeOut(100);
});
,你可以做一个小提琴?甚至无法检查您链接的网站上的元素... –
http://jsfiddle.net/hejda8yg/2/ @JeroenBellemans –