Is it possible to use :hover on :first-child:after?

混江龙づ霸主 提交于 2020-01-04 06:53:03

问题


HTML

<div>
    <div></div>
</div>

CSS

div > :first-child:after {
    background-color: orange;
    color: #fff;
    font-family: sans-serif;
    font-size: 50px;
    line-height: 50px;
    text-align: center;
    vertical-align: middle;
    -webkit-font-smoothing: antialiased;
    content: "hello world";
    display: block;
    font-size: 50px;
    height: 160px;   
    line-height: 160px;
    margin-top: 14px;
    font-weight: normal;
}
div > :first-child:after:hover {
    background-color: #44b800;
}

Fiddle

http://jsfiddle.net/VSBr6/

Basically, all I want to do is change the background-color on hover but it doesn't seem to work.


回答1:


You can do it like this:

div:first-child:hover::after {
    background-color: #44b800;
}


来源:https://stackoverflow.com/questions/15704955/is-it-possible-to-use-hover-on-first-childafter

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