What I've tried (css):
div:hover #h2 {
color: transparent;
}
I want to hide text in a div
like this:
<div>
<h2>text</h2>
</div>
You should remove the #
:
div:hover h2 {
color: transparent;
}
A #
indicates an id instead of a tag name (so you were selecting id="h2"
).
this will hide H2 tag on DIV hover
div:hover h2{
display: none;
}
if you need fix height in your DIV you can use this one:
div:hover h2{
visibility: hidden;
}
UPDATE: duo to questioner comment, if you want to use a specific id, do like this:
<div id="spdiv"><h2>message</h2></div>
and in css
#spdiv:hover h2{
display: none;
}
using #
helps you to specify element id
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.