I've written some code so a desc box will pop up when you scroll over an image, however the way it's CSS is set up I have to include the popup box in the hover class, which means when you move off the base image onto the box it stays, how can I change this so the box goes away after moving the cursor from the icon image.
<!DOCTYPE html>
<html>
<head>
<style>
p { margin-top: -6px; }
h1.d1 {
color: #0195d3;
font-size: 18px;
font-weight:bold;
font-family:"Veranda",Arial;
letter-spacing:.8px;
text-align:left;
}
p.d2 {
color:#c8c8c8;
font-size: 12px;
font-family:"Veranda",Arial;
letter-spacing:.05px;
line-height:100%;
text-align:left;
}
.desc{
background: black;
opacity: .85;
height: 140px;
width: 180px;
margin: 0 auto;
position: absolute;
text-align: center;
top: -100px;
left:-20px;
display:none;
padding:1px 20px;
}
.desc:after{
content:'';
position:absolute;
bottom:-5px;
width:20px;
height:20px;
background:black;
left:20%;
margin-left:-10px;
-moz-transform:rotate(45deg);
-webkit-transform:rotate(45deg);
transform:rotate(45deg);
}
.icon {
margin:200px;
float:left;
position:relative;
cursor:pointer;
}
.icon:hover .desc{
display:block;
}
</style>
</head>
<body>
<div class="icon">
<img src="Images/Icon/Vault.png">
<div class="desc">
<h1 class="d1">Vault</h1>
<p class="d2">9/24/13</p>
<p class="d2">Who knew a 2D platformer could also be an epic RPG quest?
Vault is about exploration and...</p>
</div>
</div>
</body>
</html>
which means when you move off the base image onto the box it stays, how can I change this so the box goes away after moving the cursor from the icon image.
By simple telling it to disappear again when it itself gets hovered:
.icon .desc:hover { display:none; }
But be aware that this might lead to a “flicker” effect if it disappearing leaves the cursor over the image again, because that will trigger the box to become visible again … so this works only really well if the box does not overlap the image.
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.