English 中文(简体)
点击孩子不会触发父子关系 : IE 的活跃状态
原标题:Clicking a child doesn t trigger the parent s :active state in IE

我在 IE 8- 10 中发现一个刺激性错误, 防止启动父元素的状态。 如果点击事件的目标为父元素的子元素, 则父元素的活跃状态不会被触发 。

< a href=> "http://jsfiddle.net/WilsonPage/6FYFj/1/" rel="noreferrer" 。这里是一个工作示例 。 如果您单击 中文本, 元素不会改变颜色。 如果您单击 中除 外的任何地方, 元素都会变成蓝色 。

这是个问题, 因为它几乎让Cs(cs)变得无益:如果元素有子女, 激活的假状态在 IE 中将毫无用处。

以前有没有人遇到过这个问题,最好找到办法解决它?

问题回答

这里简单易行:在该段增加一条cs规则。

工作示例

<强 > CSS

ul { list-style: none; }
li { height: 50px; margin-bottom: 4px; background: red; }
li:active { background: blue; }
p:active { background: blue; height: 100%;}

我通过防止儿童元素上的指针活动来解决这个问题。 这样, < code>: active 状态直接触发于父/ code 状态, 不需要传播。 此解决方案的唯一缺点是您无法将事件听众( 甚至是 Css `: hover 选择器) 附加到孩子身上。 因此您必须将您的所有活动听众移到父/ 父/ 。

.child { pointer-events: none; }

Here is jsFiddle https://jsbin.com/govelabuca/1/edit?css,output
Just uncomment the last line in css and compare the result in IE and other modern browser

您可以为 lt; p> 标签添加另一个 CSS 选择器, 这样您就可以

li:active { background: blue; }

将成为

li:active, li p:active { background: blue; }

我建议您在点击孩子的元素时 使用笔记本或缩写, 执行父母的主动状态。





相关问题
Image rendered with wrong colors in IE8

I have a gradient image as a PNG (no transparency) in a web-page. By taking a screenshot of Chrome showing the page and cropping the image from the page, I see the exact same colors are drawn as the ...

Determine Mobile Internet Explorer version

I need to determine the version of Mobile Internet Explorer on a Windows Mobile 6.1 device. So that I can report the same user-agent string as is being used by Mobile Internet Explorer. The user-...

CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

Internet Explorer only part loading JavaScript/CSS

I m having trouble with my local development environment where IE (6 through to 8) is only part loading JavaScript/CSS files. It throws random errors at random places in jquery.min.js every time I ...

IE doesn t run Javascript when you click back button

I ve built a shop with tons of JS running. One of the pieces of the cart, is a zip code field which is required to calculate shipping cost. This works fine going through the cart. Now clicking ...

热门标签