Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/380.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何将图片逐个设置为灰度动画_Javascript_Jquery_Html_Css - Fatal编程技术网

Javascript 如何将图片逐个设置为灰度动画

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%; }

这里我有3个图像,我想给它们设置动画,这样它们会在半秒后逐个变为灰度

这里是小提琴链接:

一些示例代码:

  .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;
}