Javascript 如何将图片逐个设置为灰度动画
这里我有3个图像,我想给它们设置动画,这样它们会在半秒后逐个变为灰度 这里是小提琴链接: 一些示例代码:Javascript 如何将图片逐个设置为灰度动画,javascript,jquery,html,css,Javascript,Jquery,Html,Css,这里我有3个图像,我想给它们设置动画,这样它们会在半秒后逐个变为灰度 这里是小提琴链接: 一些示例代码: .wrap { overflow: hidden; background-color: #fff; margin: 0 auto; } .box { float: left; position: relative; width: 14.285714286%; }
.wrap {
overflow: hidden;
background-color: #fff;
margin: 0 auto;
}
.box {
float: left;
position: relative;
width: 14.285714286%;
}
.boxInner img {
width: 100%;
display: block;
}
.boxInner img:hover {
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-o-filter: grayscale(100%);
}
如果要按顺序设置图像动画,可以尝试以下操作:
@-webkit-keyframes toGrayScale {
to {
-webkit-filter: grayscale(100%);
}
}
.box:nth-child(1) img {
-webkit-animation: toGrayScale 1s 0.5s forwards;
}
.box:nth-child(2) img {
-webkit-animation: toGrayScale 1s 1s forwards;
}
.box:nth-child(3) img {
-webkit-animation: toGrayScale 1s 1.5s forwards;
}
如果要按顺序设置图像动画,可以尝试以下方法:
@-webkit-keyframes toGrayScale {
to {
-webkit-filter: grayscale(100%);
}
}
.box:nth-child(1) img {
-webkit-animation: toGrayScale 1s 0.5s forwards;
}
.box:nth-child(2) img {
-webkit-animation: toGrayScale 1s 1s forwards;
}
.box:nth-child(3) img {
-webkit-animation: toGrayScale 1s 1.5s forwards;
}
如果要按顺序设置图像动画,可以尝试以下方法:
@-webkit-keyframes toGrayScale {
to {
-webkit-filter: grayscale(100%);
}
}
.box:nth-child(1) img {
-webkit-animation: toGrayScale 1s 0.5s forwards;
}
.box:nth-child(2) img {
-webkit-animation: toGrayScale 1s 1s forwards;
}
.box:nth-child(3) img {
-webkit-animation: toGrayScale 1s 1.5s forwards;
}
如果要按顺序设置图像动画,可以尝试以下方法:
@-webkit-keyframes toGrayScale {
to {
-webkit-filter: grayscale(100%);
}
}
.box:nth-child(1) img {
-webkit-animation: toGrayScale 1s 0.5s forwards;
}
.box:nth-child(2) img {
-webkit-animation: toGrayScale 1s 1s forwards;
}
.box:nth-child(3) img {
-webkit-animation: toGrayScale 1s 1.5s forwards;
}