Chrome 11 解析 CSS 规则时出现错误
我有这个滑块:
它在几乎所有浏览器(Firefox、Opera、Safari、甚至是设计师杀手浏览器 IE)。但在Chrome 11(我必须支持这个版本的Chrome)和更低版本中,右键会掉落。我正在追踪它为什么会这样,我发现了一些非常有趣的东西,但同时也很烦人。对于我的左右按钮,我有一个非常简单的 CSS 规则:
#rightBtn
{
background: url(/images/rightBtn.png) 0 0 no-repeat;
width: 56px;
height: 56px;
display: block;
float: right;
margin-top: 100px;
cursor: pointer;
margin-right: -60px;
}
#leftBtn
{
background: url(/images/leftBtn.png) 0 0 no-repeat;
width: 56px;
height: 56px;
display: block;
float: left;
margin-top: 100px;
cursor: pointer;
margin-left: -60px;
}
#leftBtn:hover, #rightBtn:hover
{
background-position: 0px -56px;
}
.definitionContent
{
width: 820px;
height: 365px;
float: left;
}
但是,当我通过 Chrome 11 的开发人员工具栏检查 rightBtn 时,看看我发现了什么:
Chrome 解析器似乎将下一个选择器 (.definitionContent
) 的 CSS 规则与我的按钮的悬停规则混合在一起。有人知道吗?
I have this slider:
And it works like a charm in almost all browsers (Firefox, Opera, Safari, and even the designer-killer browser, IE). But in Chrome 11 (I have to support this version of Chrome) and lower versions the right button falls down. I was tracking to see why it behaves so, and I came across something really interesting, but at the same time annoying. For my left and right buttons, I have a very simple CSS rules:
#rightBtn
{
background: url(/images/rightBtn.png) 0 0 no-repeat;
width: 56px;
height: 56px;
display: block;
float: right;
margin-top: 100px;
cursor: pointer;
margin-right: -60px;
}
#leftBtn
{
background: url(/images/leftBtn.png) 0 0 no-repeat;
width: 56px;
height: 56px;
display: block;
float: left;
margin-top: 100px;
cursor: pointer;
margin-left: -60px;
}
#leftBtn:hover, #rightBtn:hover
{
background-position: 0px -56px;
}
.definitionContent
{
width: 820px;
height: 365px;
float: left;
}
But, when I inspected rightBtn through Chrome 11's developer toolbar, look what I've found:
It seems that Chromes parser mixes CSS rules of the next selector (.definitionContent
) with the hover rules of my button. Anyone got any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试更改 html 的顺序( http://jsfiddle.net/PjFba/1/ ):
you can try changing the order of the html( http://jsfiddle.net/PjFba/1/ ):