我如何使文本消失并通过将鼠标悬停在另一个文本上来使其他文本出现 [英] how do I make a text disappear and make different text appear by hovering over another text
本文介绍了我如何使文本消失并通过将鼠标悬停在另一个文本上来使其他文本出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何通过悬停在另一个文本上来使文本消失并显示其他文本.
How do I make a text disappear and make different text appear by hovering over another text.
#a:hover + #b {
display: none;
}
#c {
display: none;
}
<body>
<div id="a">Hover here</div>
<div id="b">This will disappear</div>
<div id="c">This will appear</div>
</body>
推荐答案
所以我想这就是您要寻找的东西:
So I guess this is what you are looking for:
#a:hover + #b {
display: none;
}
#a:hover ~ #c {
display: block;
}
#c {
display: none;
}
<body>
<div id="a">Hover here</div>
<div id="b">This will disappear</div>
<div id="c">This will appear</div>
</body>
说明:
由于您已经在使用相邻的同级选择器(+
),用于选择紧随其后的同级元素.
Explanation:
As you are already using the adjacent sibling selector (+
) that selects the sibling element that immediately follows.
使用通用的同级选择器(~
),您可以从所有后续同级元素中进行选择.
Using the general sibling selector (~
) you can select from all the succeeding sibling elements.
让我知道您对此的反馈.谢谢!
Let me know your feedback on this. Thanks!
这篇关于我如何使文本消失并通过将鼠标悬停在另一个文本上来使其他文本出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文