gpt4 book ai didi

html - 悬停标题时的闪烁效果。不透明背景上的标题

转载 作者:太空宇宙 更新时间:2023-11-03 21:18:08 26 4
gpt4 key购买 nike

有这个 html:

<!DOCTYPE html>
<html>
<head>
<title>Image hover</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<style>
.gecoitems {list-style-type: none !important;margin:0 auto !important;width:1200px;}
.gecoitems .gecoitem {margin-bottom:20px;display:block;}
.gecoitems .column {float:left;}
.gecoitems {width:1200px;}
.gecoitems .gecoitem.normal {width:1200px;height:252px;background:#006505;color:#fff;}

/* links */
.gecoitems .gecoitem:hover {opacity:1;}
.image-listitem-wrapper {position:relative;}
.image-listitem-wrapper .title {position:absolute;top:40%;left:0;opacity:1.0;color:#ffffff;text-transform: uppercase;width:100%;text-align:center;font-size:35px;line-height:normal;}
.image-listitem-wrapper .title.hover {display:none;color:#000000;top:35%;}
.image-listitem-wrapper .title.hover .services {text-transform: lowercase;display:block;}

.gecoitems .gecoitem.wrapper-title.hover:hover {opacity:0.4;}
.gecoitems .gecoitem.wrapper-title.hover:hover + .title.hover {display:block;}


.slow-fade {
opacity: 0.8;
-webkit-transition: opacity .25s ease-in-out;
-moz-transition: opacity .25s ease-in-out;
-o-transition: opacity .25s ease-in-out;
transition: opacity .25s ease-in-out;
}

</style>

</head>
<body>
<ul class="gecoitems">
<li>
<div class="image-listitem-wrapper default-image">
<a href="#" class="wrapper-title hover slow-fade gecoitem normal"></a>
<span class="title hover">TITLE<span class="services">Subtitle</span></span>
</div>
</li>
</ul>
</body>
</html>

我几乎得到了我想要的。当我将鼠标悬停在该区域时,我得到不透明度为 0.4 的背景,上面有一个标题,但是当我将鼠标悬停在标题/副标题上时,我得到了“闪烁效果”。我不想要这种“闪烁效果”。我该如何摆脱它? (我很确定是这样的:

.gecoitems .gecoitem.wrapper-title.hover:hover + .title.hover {display:block;} 这就是问题所在,但我该如何解决呢?当我将鼠标悬停在标题上时,我不希望发生任何事情(只希望不透明度 0.4 为“留在那里”)

进一步解释的 JS Fiddle:https://jsfiddle.net/1rLzeht9/

最佳答案

你可以尝试下面的代码片段,我将一些 display:block 更改为 opacity:1,并向 添加了一个 z-index 属性。标题

为了这个片段的目的,我还移动了你的 css,去掉了 body、meta 等标签

.gecoitems {
list-style-type: none !important;
margin: 0 auto !important;
width: 1200px;
}
.gecoitems .gecoitem {
margin-bottom: 20px;
display: block;
}
.gecoitems .column {
float: left;
}
.gecoitems {
width: 1200px;
}
.gecoitems .gecoitem.normal {
width: 1200px;
height: 252px;
background: #006505;
color: #fff;
}
/* links */

.gecoitems .gecoitem:hover {
opacity: 1;
}
.image-listitem-wrapper {
position: relative;
}
.image-listitem-wrapper .title {
position: absolute;
top: 40%;
left: 0;
opacity: 1.0;
color: #ffffff;
text-transform: uppercase;
width: 100%;
text-align: center;
font-size: 35px;
line-height: normal;
z-index:-1;
}
.image-listitem-wrapper .title.hover {
opacity: 0;
color: #000000;
top: 35%;
}
.image-listitem-wrapper .title.hover .services {
text-transform: lowercase;
display: block;
}
.gecoitems .gecoitem.wrapper-title.hover:hover {
opacity: 0.4;
}
.gecoitems .gecoitem.wrapper-title.hover:hover + .title.hover {
opacity: 1;
}
.title:hover {
opacity: 1 !important;
}
.slow-fade {
opacity: 0.8;
-webkit-transition: opacity .25s ease-in-out;
-moz-transition: opacity .25s ease-in-out;
-o-transition: opacity .25s ease-in-out;
transition: opacity .25s ease-in-out;
}
<body>
<ul class="gecoitems">
<li>
<div class="image-listitem-wrapper default-image">
<a href="#" class="wrapper-title hover slow-fade gecoitem normal"></a>
<span class="title hover">TITLE<span class="services">Subtitle</span></span>
</div>
</li>
</ul>
</body>

您还可以添加 pointer-events:none.title 元素,参见 This Fiddle .这删除了作为鼠标事件目标的标题

关于html - 悬停标题时的闪烁效果。不透明背景上的标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40099940/

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