gpt4 book ai didi

html - div下超链接无法点击

转载 作者:行者123 更新时间:2023-11-28 03:46:04 24 4
gpt4 key购买 nike

我尝试过使用 z-indexposition:relative 进行试验,但我似乎无法让它发挥作用。

我已经做到了,一旦您将鼠标悬停在图像上,就会出现一个超链接,但由于某种原因您无法单击该超链接。有人可以告诉我如何把它带到前面吗?

这是我的代码:

.caption {
display: inline-block;
position: relative;
overflow: hidden;
-webkit-transform: translateZ(0);
margin-right: 1.25em;
margin-top: 1.250em;
margin-bottom: 2.188em;
margin-left: 1.25em;
top: 0;
bottom: 0;
right: 0;
display: block;
max-width: 100%;
height: auto;
}

.caption::before {
content: ' ';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: transparent;
transition: background .35s ease-out;
}

.imageh:hover+.caption::before {
box-shadow: inset 0 0 0 1000px rgba(0, 0, 0, .5);
}

.imageh {
position: absolute;
display: block;
height: 100%;
width: 100%;
z-index: 1;
top: 0;
bottom: 0;
right: 0;
}

.caption__overlay {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
padding: 10px;
color: white;
-webkit-transform: translateY(100%);
transform: translateY(100%);
transition: -webkit-transform .35s ease-out;
transition: transform .35s ease-out;
}

.imageh:hover+.caption .caption__overlay {
-webkit-transform: translateY(0);
transform: translateY(0);
}

.caption__media {
padding-top: 130px;
max-width: 100%;
}
<span class="imageh"></span>
<div class="caption">
<img src="http://bsnscb.com/data/out/78/27073638-free-farm-wallpapers.jpg" />
<div class="caption__overlay">
<div class="caption__overlay__content">
<h1 style="text-align:center" class="caption__media"><a style="color:white;" href="artists.html">OUR ARTISTS</a></h1>
</div>
</div>
</div>

谢谢

最佳答案

而不是在悬停时使用与图像容器同级的 span 元素(这使得悬停期间难以避免闪烁)。您可以将鼠标悬停在标题容器 div 本身上。请参阅下面的示例代码

.caption {
display: inline-block;
position: relative;
overflow: hidden;
-webkit-transform: translateZ(0);
margin-right: 1.25em;
margin-top: 1.250em;
margin-bottom: 2.188em;
margin-left: 1.25em;
top: 0;
bottom: 0;
right: 0;
display: block;
max-width: 100%;
height: auto;

}

.caption::before {
content: ' ';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: transparent;
transition: background .35s ease-out;
}

.caption:hover::before {
box-shadow: inset 0 0 0 1000px rgba(0, 0, 0, .5);
}

.imageh {
/* position: absolute;
display: block;
height: 100%;
width: 100%;
z-index: 1;
top: 0;
bottom: 0;
right: 0;*/
}

.caption__overlay {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
padding: 10px;
color: white;
-webkit-transform: translateY(100%);
transform: translateY(100%);
transition: -webkit-transform .35s ease-out;
transition: transform .35s ease-out;

}

.caption:hover .caption__overlay {
-webkit-transform: translateY(0);
transform: translateY(0);
}

.caption__media {
padding-top: 130px;
max-width: 100%;
}
<span class="imageh"></span>
<div class="caption">
<img src="https://homepages.cae.wisc.edu/~ece533/images/arctichare.png" />
<div class="caption__overlay">
<div class="caption__overlay__content">
<h1 style="text-align:center" class="caption__media"><a style="color:white;" href="artists.html">OUR ARTISTS</a></h1>
</div>
</div>
</div>

关于html - div下超链接无法点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43971317/

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