我应该如何编辑这段代码来制作反转模糊效果?
How should I edit this code to make an invert blur effect?
这是我从博客上复制的代码
here is the link cause I can't seem to make it work here
我希望它首先是模糊,然后在悬停时模糊应该消失。
这是我的测试博客>(已收藏)
如果您将鼠标悬停在 post 的缩略图上,您会看到它正在模糊,
所以,我想要的是 - 我希望该缩略图首先模糊,当悬停时模糊应该消失。
请帮忙。谢谢
简单一点的代码,达到你想要的效果:
figure {
background: black;
color: white;
width: 20em;
}
figure .image {
background: transparent url("") center/0 0 no-repeat;
overflow: hidden;
position: relative;
}
figure .image:before,
figure .image:after {
background-image: inherit;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
content: "";
display: block;
filter: blur(5px);
transform: scale(1.1);
}
figure .image:before {
padding-top: 66.6667%; // define image ratio. Here 3:2
}
figure .image:after {
height: 100%;
left: 0;
position: absolute;
top: 0;
transition: filter 200ms;
width: 100%;
z-index: 1;
}
figure figcaption {
padding: 1em;
}
figure:hover .image:after {
filter: blur(0px);
}
<figure>
<div class="image" style="background-image: url(http://loremflickr.com/900/600/brazil,rio)"></div>
<figcaption>Some caption</figcaption>
</figure>
在您的代码中搜索
.gallery-wrapper:hover img.gallry_img {
-webkit-transition: all 0.4s ease-in-out;
-moz-transition: all 0.4s ease-in-out;
-o-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
-webkit-filter: blur(-3px);
filter: blur(-3px);
-moz-filter: blur(-3px);
}
并替换为下一个
.gallery-wrapper img.gallry_img {
-webkit-transition: all 0.4s ease-in-out;
-moz-transition: all 0.4s ease-in-out;
-o-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
-webkit-filter: blur(-3px);
filter: blur(-3px);
-moz-filter: blur(-3px);
}
.gallery-wrapper:hover img.gallry_img {
-webkit-filter: blur(0px);
filter: blur(0px);
-moz-filter: blur(0px);
}
感谢您更新您的原始问题以澄清您实际提出的问题。看了你的博客,我明白了你想要达到的目标。
你需要的是一个基本的模糊滤镜,当图像悬停时关闭,这可以使用 CSS filter: blur();
属性 除了简单的 :hover
选择器。
在图像的默认样式中,模糊滤镜应默认设置为模糊,因此 CSS 将为:
.image {
filter: blur(3px);
transition: all 0.3s;
}
注意:上面的transition
属性使模糊效果达到'fade'。
当您将鼠标悬停在图像 (.image:hover
) 上时,滤镜会发生变化,图像上不再出现模糊,因此 CSS 将是:
.image:hover {
filter: blur(0px);
}
如果您想了解更多关于 CSS 滤镜模糊效果的信息,have a look here。
我已将以上内容编译成一个 JSFiddle 示例供您使用,希望能更好地解释我的答案:Example
如果您还有其他问题,请随时提问。
这是我从博客上复制的代码
here is the link cause I can't seem to make it work here
我希望它首先是模糊,然后在悬停时模糊应该消失。
这是我的测试博客>(已收藏)
如果您将鼠标悬停在 post 的缩略图上,您会看到它正在模糊, 所以,我想要的是 - 我希望该缩略图首先模糊,当悬停时模糊应该消失。
请帮忙。谢谢
简单一点的代码,达到你想要的效果:
figure {
background: black;
color: white;
width: 20em;
}
figure .image {
background: transparent url("") center/0 0 no-repeat;
overflow: hidden;
position: relative;
}
figure .image:before,
figure .image:after {
background-image: inherit;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
content: "";
display: block;
filter: blur(5px);
transform: scale(1.1);
}
figure .image:before {
padding-top: 66.6667%; // define image ratio. Here 3:2
}
figure .image:after {
height: 100%;
left: 0;
position: absolute;
top: 0;
transition: filter 200ms;
width: 100%;
z-index: 1;
}
figure figcaption {
padding: 1em;
}
figure:hover .image:after {
filter: blur(0px);
}
<figure>
<div class="image" style="background-image: url(http://loremflickr.com/900/600/brazil,rio)"></div>
<figcaption>Some caption</figcaption>
</figure>
在您的代码中搜索
.gallery-wrapper:hover img.gallry_img {
-webkit-transition: all 0.4s ease-in-out;
-moz-transition: all 0.4s ease-in-out;
-o-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
-webkit-filter: blur(-3px);
filter: blur(-3px);
-moz-filter: blur(-3px);
}
并替换为下一个
.gallery-wrapper img.gallry_img {
-webkit-transition: all 0.4s ease-in-out;
-moz-transition: all 0.4s ease-in-out;
-o-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
-webkit-filter: blur(-3px);
filter: blur(-3px);
-moz-filter: blur(-3px);
}
.gallery-wrapper:hover img.gallry_img {
-webkit-filter: blur(0px);
filter: blur(0px);
-moz-filter: blur(0px);
}
感谢您更新您的原始问题以澄清您实际提出的问题。看了你的博客,我明白了你想要达到的目标。
你需要的是一个基本的模糊滤镜,当图像悬停时关闭,这可以使用 CSS filter: blur();
属性 除了简单的 :hover
选择器。
在图像的默认样式中,模糊滤镜应默认设置为模糊,因此 CSS 将为:
.image {
filter: blur(3px);
transition: all 0.3s;
}
注意:上面的transition
属性使模糊效果达到'fade'。
当您将鼠标悬停在图像 (.image:hover
) 上时,滤镜会发生变化,图像上不再出现模糊,因此 CSS 将是:
.image:hover {
filter: blur(0px);
}
如果您想了解更多关于 CSS 滤镜模糊效果的信息,have a look here。
我已将以上内容编译成一个 JSFiddle 示例供您使用,希望能更好地解释我的答案:Example
如果您还有其他问题,请随时提问。