简体   繁体   English

伪元素不可点击

[英]Pseudo-element not clickable

I've placed an arrow as an :after pseudo-element of a clickable tile. 我将箭头放置为:在可点击的瓷砖的伪元素之后。 It creates a blind spot that is not clickable despite setting the height/width to 0. 尽管将高度/宽度设置为0,它仍会产生无法点击的盲点。

Code here: http://cdpn.io/vpjCg 代码在这里: http//cdpn.io/vpjCg

To see the issue, roll cursor over the tiled link, then over the character in the bottom-right corner. 要查看问题,请将光标滚动到平铺链接上,然后滚动到右下角的字符上。

Is there a CSS attribute or another solution to set the :after element as invisible to the mouse cursor so that the whole area is clickable? 是否有CSS属性或其他解决方案将:after元素设置为鼠标光标不可见,以便整个区域可单击?

Pseudo elements belong to their parents - if their parent is clickable ( button , a ) then so will the pseudo element. 伪元素属于他们的父母 - 如果他们的父母是可点击的( buttona )那么伪元素也是如此。 Likewise with DOM elements, if a DOM element has a click event listener bound, it will be fired when you click directly on the DOM element, or on it's pseudo elements. 与DOM元素类似,如果DOM元素绑定了click事件侦听器,则直接单击DOM元素或其上的伪元素时将触发它。

EDIT 编辑

In addition to my answer, you can make your clicks go "through" an element to hit underlying elements using the CSS property pointer-events and setting the value to none . 除了我的回答之外,您可以使用CSS属性pointer-events并将值设置为none ,使您的点击“遍历”一个元素以触发底层元素。 Works in every modern browser (IE9 and up) https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events 适用于所有现代浏览器(IE9及更高版本) https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM