我有一个带有下拉菜单的项目。这是HTML:
<div class="body">
<div class="head"></div>
<div class="navbar">
<div>Home</div>
<div id="items"><p>Items</p>
<div class="idd">
<table class="dd">
<tr>
<td><a href="./items/weapons.html">Weapons</a></td>
</tr>
<tr>
<td><a href="./items/abilities.html">Abilities</a></td>
</tr>
<tr>
<td><a href="./items/armor.html">Armor</a></td>
</tr>
<tr>
<td><a href="./items/rings.html">Rings</a></td>
</tr>
</table>
</div>
</div>
<div>Sets</div>
<div>Contact</div>
<div>Info</div>
<div>Donations</div>
</div>
</div>
所以,现在这里是 CSS:
div.body {
width: 1000px;
margin-left: auto;
margin-right: auto;
margin-top: 15px;
}
div.body div.head {
background-image: url("header.png");
width: 995px;
height: 200px;
margin-left: auto;
margin-right: auto;
}
div.navbar div {
font-size: 13pt;
padding-top: 10px;
display: inline-block;
margin-left: 10px;
padding-left: 8px;
padding-right: 8px;
padding-bottom: 10px;
}
div.navbar div:hover {
background-color: #666;
}
div.navbar {
font-family: 'HelveticaNeue';
background-image: url("../newsdcs/navbarbg.png");
width: 730px;
height: 40px;
margin-top: 15px;
border-radius: 5px;
text-align: center;
margin-left: auto;
margin-right: auto;
color: #F0F0F0;
}
div.navbar div p {
margin-top: 0;
margin-bottom: 0;
}
div.navbar div div.idd {
background-color: #666;
position: absolute;
}
a {
color: white;
text-decoration: none;
}
是的,这是 JQuery:
$(document).ready(function(){
window.onload = function() {
if(!window.location.hash) {
window.location = window.location + '#l';
window.location.reload();
}
}
$(".idd").hide();
var eTop = $('#items').offset().top;
var eLeft = $('#items').offset().left;
var eTopA = eTop + 40;
var eLeftA = eLeft;
$(".idd").offset({ top: eTopA, left: eLeftA });
$("#items").hover(function() {
$(".idd").show();
}, function() {
$(".idd").hide();
});
});
在每个人的浏览器和计算机上,他们会得到不同的结果。稍微偏离中心,在错误的地方,刷新,你会得到正确的结果,错误的结果,无论如何。如何制作一致、居中、正确且一致的下拉菜单?非常感谢!