before pseudoelement in Chrome

北城以北 提交于 2019-12-23 15:10:15

问题


It appears to me that Chrome does not treat "before" pseudoelement as a part of an element. More precisely, I have CSS definition

.myclass:before{content:"A";}

and HTML code

<a href="blah" class="myclass">B</a>

In Chrome the result is a hyperlink "AB" but only "B" is actually clickable. In Firefox and Opera the whole "AB" is a link, and my reading of CSS standard indicates that Chrome is wrong here.

Am I right in assuming that this is Chrome's bug? Is there a simple and clean workaround?


回答1:


It seems that you can work around it with:

.myclass {
    display: inline-block
}

http://jsfiddle.net/SUKYw/

Looks like a Chrome bug - Safari does not have the same problem.



来源:https://stackoverflow.com/questions/6480495/before-pseudoelement-in-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!