html - 将链接添加到图像会破坏其他所有内容
问题描述
所以这是一个简单的图像行,带有悬停效果,我可以做我需要的一切,除非我添加一个链接来打开一个新页面 ,所以我需要重新制作所有内容并使用不同的方法或者有没有办法以某种方式解决问题?谢谢 :)
更新!
代码可能并不完美,但我添加了
.box-1 a { 显示:内容:}
这解决了一切!
.container-1 {
display: inline-flex;
}
.box-1 {
-webkit-box-flex: 1;
-moz-box-flex: 1;
box-flex: 1;
-webkit-flex: 1 1 auto;
flex: 1 1 auto;
padding: 30px;
text-align: center;
display: inline-block;
position: relative;
}
.box-1:hover img {
filter: blur(3px) brightness(85%);
}
.box-1 img {
width: 100%;
height: 100%;
transition: 0.1s;
}
.box-1 :not(img) {
position: absolute;
top: 30%;
z-index: 1;
color: #fff;
text-align: center;
width: 90%;
opacity: 0;
transition: 0.1s;
letter-spacing: 2px;
}
.box-1 h2 {
top: 50%;
}
.box-1:hover :not(img) {
opacity: 1;
}
<div class="container-1">
<div class="box-1">
<a href="c1.html" target="_blank">
<img class="candle-image" src="image/candlesp/IMG_0900.jpg"/></a>
<h2>Festivity</h2>
</div>
<div class="box-1">
<img src="image/candlesp/IMG_0903.jpg" alt="">
<h2>Cinnamon</h2>
</div>
<div class="box-1">
<img src="image/candlesp/IMG_0917.jpg" alt="">
<h2>Forest</h2>
</div>
</div>
解决方案
我想你是不小心弄的<a>
position: absolute
。而不是使用:not
,为什么不h2
直接定位.box-1 h2
并尝试给它一个宽度和高度
推荐阅读
- c# - Amazon S3 密钥不存在
- intellij-idea - 更改 Groovy 类后 IntelliJ 不会重新加载类定义
- jquery - 如何将 JQuery 选择器分配给变量
- c# - SQLite 插入数据非常慢,即使使用 BEGIN/COMMIT TRANSACTION
- javascript - 使用带有角度的 REST api 访问共享点列表给出 403
- amazon-ec2 - EC2 端口 22:连接超时
- dynamics-crm - 在 Dynamics CRM Online 中添加新记录时更新关联视图中的记录
- java - Sendgrid v3:“替换不能与动态模板一起使用”
- amazon-web-services - 为什么我只能将 AWS S3 存储桶事件发送到一个 AWS lambda?
- bash - 跨多个文件替换重复的 uuid