4
我需要使用CSS製作灰度到rgba的圖片。我知道我可以用CSS3改變它,但我需要一個平滑的動畫。我需要用動畫從底部到頂部填充顏色。我附上一張圖片來說明問題。在css3中創建從下到上的灰度效果
請檢查該fiddle,這是我做的那麼遠。
HTML:
<img src="http://static.wallpedes.com/wallpaper/resolution/resolution-of-wallpaper-pictures-with-green-eyes-hd-best-girls-full-hd-wallpapers-wallpaper-site-for-mobile-android-download-facebook-2012-app-in-the-world.jpg"/>
CSS:
img {
-webkit-animation: mymove 5s;
-moz-animation: mymove 5s;
-ms-animation: mymove 5s;
animation: mymove 5s;
width: 400px;
}
@-webkit-keyframes mymove {
0% {
-webkit-filter: grayscale(100%);
-mos-filter: grayscale(100%);
-moz-filter: grayscale(100%);
filter: grayscale(100%);
}
100% {
-webkit-filter: grayscale(0%);
-mos-filter: grayscale(0%);
-moz-filter: grayscale(0%);
filter: grayscale(0%);
}
}
@-moz-keyframes mymove {
0% {
-webkit-filter: grayscale(100%);
-mos-filter: grayscale(100%);
-moz-filter: grayscale(100%);
filter: grayscale(100%);
}
100% {
-webkit-filter: grayscale(0%);
-mos-filter: grayscale(0%);
-moz-filter: grayscale(0%);
filter: grayscale(0%);
}
}
@-ms-keyframes mymove {
0% {
-webkit-filter: grayscale(100%);
-mos-filter: grayscale(100%);
-moz-filter: grayscale(100%);
filter: grayscale(100%);
}
100% {
-webkit-filter: grayscale(0%);
-mos-filter: grayscale(0%);
-moz-filter: grayscale(0%);
filter: grayscale(0%);
}
}
/* Standard syntax */
@keyframes mymove {
0% {
-webkit-filter: grayscale(100%);
-mos-filter: grayscale(100%);
-moz-filter: grayscale(100%);
filter: grayscale(100%);
}
100% {
-webkit-filter: grayscale(0%);
-mos-filter: grayscale(0%);
-moz-filter: grayscale(0%);
filter: grayscale(0%);
}
}
在此先感謝。
你忘了小提琴鏈接 – Crock
對不起,我已經更新了它... – hakkim