我在导航图像的精灵上使用背景位置。它在 chrome、safari、ff 等中看起来很棒。水平属性似乎在 IE 中有效,但在垂直时无效。到处都是。相反,我在不同的站点上有几乎完全相同的代码,但是那个精灵是水平设置的。
这是CSS。我添加了 background-position-x/y 作为潜在的修复,但 IE 似乎也不受此影响(除非 Winebottler IE7 安装存在缓存错误)。我是新手,所以这将解释任何菜鸟的东西:
#menu-item-16 a {
background-image: url("images/csg.png");
background-position: 0 -510px;
background-position-x: 0;
background-position-y: -510px;
background-repeat: no-repeat;
background-size: 400px auto;
display: block;
height: 80px;
margin-left: 0;
margin-top: -13px;
outline: none;
padding: 0;
text-indent: -9999px;
width: 400px;
}
#menu-item-16 a:hover {
background-position: 0 -638px;
background-position-x: 0;
background-position-y: -638px;
}
#menu-item-24 a {
background-image: url("images/csg.png");
background-position: 0 0;
background-position-x: 0;
background-position-y: 0;
background-repeat: no-repeat;
background-size: 400px auto;
display: block;
height: 80px;
margin-left: 0;
margin-top: -10px;
outline: none;
padding: 0;
text-indent: -9999px;
width: 400px;
}
#menu-item-24 a:hover {
background-position: 0 -128px;
background-position-x: 0;
background-position-y: -128px;
}
#menu-item-15 a {
background-image: url("images/csg.png");
background-position: 0 -1025px;
background-position-x: 0;
background-position-y: -1025px;
background-repeat: no-repeat;
background-size: 400px auto;
display: block;
height: 80px;
margin-left: 0;
margin-top: -13px;
outline: none;
padding: 0;
text-indent: -9999px;
width: 400px;
}
#menu-item-15 a:hover {
background-position: 0 -1153px;
background-position-x: 0;
background-position-y: -1153px;
}
#menu-item-13 a {
background-image: url("images/csg.png");
background-position: 0 -1282px;
background-position-x: 0;
background-position-y: -1282px;
background-repeat: no-repeat;
background-size: 400px auto;
display: block;
height: 80px;
margin-left: 0;
margin-top: -13px;
outline: none;
padding: 0;
text-indent: -9999px;
width: 400px;
}
#menu-item-13 a:hover {
background-position: 0 -1409px;
background-position-x: 0;
background-position-y: -1409px;
}
#menu-item-14 a {
background-image: url("images/csg.png");
background-position: 0 -769px;
background-position-x: 0;
background-position-y: -769px;
background-repeat: no-repeat;
background-size: 400px auto;
display: block;
height: 80px;
margin-left: 0;
margin-top: -13px;
outline: none;
padding: 0;
text-indent: -9999px;
width: 400px;
}
#menu-item-14 a:hover {
background-position: 0 -897px;
background-position-x: 0;
background-position-y: -897px;
}
#menu-item-28 a {
background-image: url("images/csg.png");
background-position: 0 -257px;
background-position-x: 0;
background-position-y: -257px;
background-repeat: no-repeat;
background-size: 400px auto;
display: block;
height: 80px;
margin-left: 0;
margin-top: -13px;
outline: none;
padding: 0;
text-indent: -9999px;
width: 400px;
}
#menu-item-28 a:hover {
background-position: 0 -385px;
background-position-x: 0;
background-position-y: -385px;
}