【发布时间】:2022-03-26 23:30:14
【问题描述】:
好的,所以。我有问题。
我想要一张在悬停时模糊的图片,同时让文字出现在它上面。
我找到了一种简单的方法来模糊图像和使文本出现,但不能同时进行;事实上,将这两个代码合并在一起使它看起来就像图片根本没有模糊一样。我认为这是因为文本实际上覆盖了图像并且浏览器没有收到图像被悬停的消息。
这里是the image with text over it,这里是the image with blur on hover 我该如何解决这个问题?我正在苦苦挣扎,我想我已经找到了另一种方法,但这有点麻烦。
这是一些代码:
h1,p {
margin: 0;
padding: 0;
}
.imgtext {
color: white;
background: rgba(0,0,0,0.89);
width: 155px;
height: 135px;
padding: 50px 15px 0 15px;
opacity: 0;
position: absolute;
bottom: 0px;
-webkit-transition: all 300ms ease-in-out;
-o-transition: all 300ms ease-in-out;
transition: all 300ms ease-in-out;
}
.pic {
position: relative;
overflow: hidden;
width: 185px;
height: 185px;
margin: 50px auto;
}
.pic img:hover{
-webkit-transition: all 300ms ease-in-out;
-o-transition: all 300ms ease-in-out;
transition: all 300ms ease-in-out;
-webkit-filter: blur(1px);
-moz-filter: blur(1px);
-ms-filter: blur(1px);
-o-filter: blur(1px);
filter: blur(1px);
transform: scale(1.03);
}
.imgtext:hover {
-webkit-opacity: 100;
opacity: 100;
}
<div class="pic">
<img src="http://nicolacornolti.com/photos/film/img/1.png">
<span class="imgtext">
<h1>THIS IS A TITLE</h1>
<p>and this is a description</p>
</span>
【问题讨论】:
标签: html css image animation css-selectors