Html 悬停在跨度内不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17296643/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
hover not working in span
提问by Fabrizio Calderan
In my code. I am displaying title in anchor <a>
tag and author name inside anchor in span tag. I write code for hover on anchor tag when hover on span it is working fine , but when hover on <a>
it is only change hover effect on anchor tag and not change color for span.
在我的代码中。我在锚<a>
标签中显示标题,在跨度标签中的锚内显示作者姓名。当悬停在跨度上时,我编写了悬停在锚标签上的代码,它工作正常,但是当悬停在<a>
它上面时,只会更改锚标签上的悬停效果,而不会更改跨度的颜色。
HTML :-
HTML :-
<a href "#" class="link">
This is my link title
<span class="span-text">Author Name</span>
</a>
Css :-
CSS :-
span {
color: #ccc;
}
a {
color: #000;
display: inline-block;
}
a:hover, span:hover {
color:#9A1A4A;
}
fiddle here
在这里摆弄
回答by Fabrizio Calderan
回答by CBroe
!important
is yuck, and not needed here.
!important
很糟糕,这里不需要。
a:hover, a:hover span {
color:#9A1A4A;
}
回答by Falguni Panchal
please try this
请试试这个
http://jsfiddle.net/roop1886/2cEYc/
http://jsfiddle.net/roop1886/2cEYc/
css :
css :
span {
color: #ccc;
}
a {
color: #000;
display: inline-block;
}
a:hover, a:hover span {
color:#9A1A4A;
}