我用图像替换了一个菜单项,并使用下面的代码对其进行了样式设置。它在Firefox、Chrome、Safari和Opera中看起来不错,但在IE中似乎忽略了相对定位。
li#menu-item-19 a {
display: block;
background-image: url('images/logo.png');
background-repeat: no-repeat;
width: 124px;
height: 120px;
text-indent: -9000px;
margin-right: -42.5px;
margin-left: -42.5px;
position: relative;
top: -31px;
margin-top: -31px;
z-index: 1;
}
我没有显示完整的网站,因为它不是实时的,但我已经设置了一个更简单的版本,我可以复制这个问题。
http://labs.comule.com/
感谢:)
这是因为您在站点中使用了内联块而导致的错误。。。。
试试这个
将DOCTYPE添加到您的html、
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
添加此项后,它对我有效。
这个网站给了我以下解释:http://robertnyman.com/2010/02/24/css-display-inline-block-why-it-rocks-and-why-it-sucks/
所以基本上我所做的是添加垂直对齐:顶部;到li元素,然后我删除了margin-top:-31px;来自li#menu-item-19a.
我希望这能帮助其他人!