CSS选择器:活动不工作在IE8中的子元素单击 [英] CSS selector :active not working on child element click in IE8
本文介绍了CSS选择器:活动不工作在IE8中的子元素单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下HTML结构:
I have the following HTML structure:
<div id="ctr__Wrapper" class="wrapper">
<div id="ctr" class="control clickable">
<img src="logo.png">
</div>
</div>
并且以下CSS:
.control
{
border: 1px solid #000;
background-color: #666;
padding: 20px;
}
.control:active
{
background-color: #bbb;
}
当我点击元素ctr时, ,但是当我点击图像本身,它不会。这在Firefox中工作正常,但不是在IE8。在CSS中,我可以做些什么来解决这个问题。
When I click on the element "ctr", I see the background color changing, but when I click on the image itself, it doesn't. This works fine in Firefox, but not in IE8. Is there something I can do to solve this in CSS.
工作示例可以在这里看到:
http://jsfiddle.net/miljenko/DNMPd/
The working example can be seen here: http://jsfiddle.net/miljenko/DNMPd/
推荐答案
您可以使用背景图片,而不是真实图片。
You could use a background image instead of a real image.
html:
<div id="ctr__Wrapper" class="wrapper">
<div id="ctr" class="control clickable">
</div>
</div>
css:
.control
{
border: 1px solid #000;
background-color: #666;
height: 40+height-of-logopx;
background-image:url(logo.png); background-repeat:no-repeat;
background-position:20px 20px;
}
.control:active
{
background-color: #bbb;
}
这篇关于CSS选择器:活动不工作在IE8中的子元素单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文