Learn how to display an element on hover.
<div class="myDIV">Hover over me.</div>
<div class="hide">I am shown when someone hovers over the div above.</div>
.hide {
display: none;
}
.myDIV:hover + .hide {
display: block;
color: red;
}
Try it Yourself »
The adjacent sibling selector (+
) selects all elements that are the adjacent siblings of a specified element.
The word "adjacent" means "immediately following", and the example above selects all elements with class=".hide"
, that are placed immediately after elements with class=".myDIV
", on hover.
Go to our CSS Combinators Tutorial to learn more about adjacent selectors.
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!