gpt4 book ai didi

html - 如何使用 CSS 排除悬停效果

转载 作者:行者123 更新时间:2023-11-28 12:13:43 25 4
gpt4 key购买 nike

我写了一些代码,所以当你滚动图像时会弹出一个 desc 框,但是它的 CSS 设置方式我必须在悬停类中包含弹出框,这意味着当你离开将基本图像放到它保留的框上,如何更改它以便在将光标从图标图像上移开后框消失。

<!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.

通过简单地告诉它在悬停时再次消失:

.icon .desc:hover { display:none; }

但请注意,如果它消失时光标再次留在图像上,这可能会导致“闪烁”效果,因为这会触发框再次变得可见……所以只有当框不重叠时这才有效图片。

http://jsfiddle.net/XVgcT/

关于html - 如何使用 CSS 排除悬停效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19329136/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com