2016-11-29 12 views
-1

フィルタを配置しようとしています。私のPNG画像にグレースケールがありますが、何らかの理由で機能しません。グレースケールのPNG画像

私のイメージ(山、フォトショップ、透明な背景)から一部を切り取った。それを私の背景イメージの上に置きます。私は私の山を回転させるように変換しようとすると動作していますが、グレースケールにしようとすると動作しません。ここ

は私のHTMLコードです:ここ

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="UTF-8"> 
<link rel="stylesheet" href="css/style.css"> 
<title>Document</title> 
</head> 
<body> 

<div id="container"> 
<div id="vrouw"></div> 
<div id="hoofd"></div> 
<div id="berg"></div> 
</div> 


</body> 
</html> 

は私のCSSコードです:

#container { 
position: relative; 
margin: 0 auto; 
width: 801px; 
height: 1233px; 
} 

#vrouw { 
background-image: url(../img/vrouw2.jpg); 
width: 801px; 
height: 1233px; 
margin: auto; 
z-index: 1; 
} 

#hoofd { 
background-image: url(../img/hoofd.png); 
width: 164px; 
height: 213px; 
position: absolute; 
top: 200px; 
left: 250px; 
animation-name: huufd; 
animation-duration: 6s; 
animation-iteration-count:infinite; 
animation-timing-function: linear; 
z-index: 3; 
} 


@keyframes huufd { 
0% { 
    transform: rotate(0deg); 
} 
10% { 
    transform: rotate(-10deg); 
} 
20% { 
    transform: rotate(-5deg); 
} 
30% { 
    transform: rotate(10deg); 
} 
40% { 
    transform: rotate(5deg); 
} 
50% { 
    transform: rotate(0deg); 
} 
60% { 
    transform: translate(5px); 
} 
70% { 
    transform: translate(-5px); 
} 
80% { 
    transform: translateY(3px); 
} 
90% { 
    transform: translateY(-3px); 
} 
100% { 
    transform: translateY(0px); 
    transform: translate(0px); 
} 
} 

#berg { 
background-image: url(../img/mountain.png); 
width: 801px; 
height: 518px; 
top: 0px; 
left: 0px; 
position: absolute; 
animation-name: bergk; 
animation-iteration-count: infinite; 
animation-duration: 3s; 
animation-timing-function: linear; 
z-index: 2; 
} 


@keyframes bergk { 
0% { 
    filter: grayscale(10%); 
} 
10% { 
    filter: grayscale(30%); 
} 
20% { 
    filter: grayscale(20%); 
} 
30% { 
    filter: grayscale(40%); 
} 
40% { 
    filter: grayscale(60%); 
} 
50% { 
    filter: grayscale(90%); 
} 
60% { 
    filter: brightness(10%); 
} 
70% { 
    filter: brightness(30%); 
} 
80% { 
    filter: brightness(20%); 
} 
90% { 
    filter: brightness(40%); 
} 
100% { 
    filter: brightness(90%); 
} 
} 
+0

は、あなたの質問を投稿する前にビットを検索しようとしたことがあり追加されましたか? http://stackoverflow.com/questions/16340159/greyscale-background-css-images – Vel

答えて

0
トレイでき

#container-webkit-filter: grayscale(100%);filter: grayscale(100%);を追加して、全体をグレースケールにします。それはキーフレームでも機能します。ここで私はデモ

#container { 
 
position: relative; 
 
margin: 0 auto; 
 
width: 801px; 
 
height: 1233px; 
 
} 
 

 
#vrouw { 
 
background-image: url('https://www.google.co.in/logos/doodles/2016/jagadish-chandra-boses-158th-birthday-5756743989592064.2-hp.png'); 
 
width: 801px; 
 
height: 1233px; 
 
margin: auto; 
 
z-index: 1; 
 
} 
 

 
#hoofd { 
 
background-image: url('https://www.google.co.in/logos/doodles/2016/jagadish-chandra-boses-158th-birthday-5756743989592064.2-hp.png'); 
 
width: 164px; 
 
height: 213px; 
 
position: absolute; 
 
top: 200px; 
 
left: 250px; 
 
animation-name: huufd; 
 
animation-duration: 6s; 
 
animation-iteration-count:infinite; 
 
animation-timing-function: linear; 
 
z-index: 3; 
 
} 
 

 

 
@keyframes huufd { 
 
0% { 
 
    transform: rotate(0deg); 
 
} 
 
10% { 
 
    transform: rotate(-10deg); 
 
} 
 
20% { 
 
    transform: rotate(-5deg); 
 
} 
 
30% { 
 
    transform: rotate(10deg); 
 
} 
 
40% { 
 
    transform: rotate(5deg); 
 
} 
 
50% { 
 
    transform: rotate(0deg); 
 
} 
 
60% { 
 
    transform: translate(5px); 
 
} 
 
70% { 
 
    transform: translate(-5px); 
 
} 
 
80% { 
 
    transform: translateY(3px); 
 
} 
 
90% { 
 
    transform: translateY(-3px); 
 
} 
 
100% { 
 
    transform: translateY(0px); 
 
    transform: translate(0px); 
 
} 
 
} 
 

 
#berg { 
 
background-image: url('https://www.google.co.in/logos/doodles/2016/jagadish-chandra-boses-158th-birthday-5756743989592064.2-hp.png'); 
 
width: 801px; 
 
height: 518px; 
 
top: 0px; 
 
left: 0px; 
 
position: absolute; 
 
animation-name: bergk; 
 
animation-iteration-count: infinite; 
 
animation-duration: 3s; 
 
animation-timing-function: linear; 
 
z-index: 2; 
 
} 
 

 

 
@keyframes bergk { 
 
0% { 
 
    filter: grayscale(10%); 
 
} 
 
10% { 
 
    filter: grayscale(30%); 
 
} 
 
20% { 
 
    filter: grayscale(20%); 
 
} 
 
30% { 
 
    filter: grayscale(40%); 
 
-webkit-filter: grayscale(100%); 
 
-moz-filter: grayscale(100%); 
 
-moz-filter: grayscale(100%); 
 
filter: grayscale(100%); 
 
} 
 
40% { 
 
    filter: grayscale(60%); 
 
-webkit-filter: grayscale(100%); 
 
-moz-filter: grayscale(100%); 
 
-moz-filter: grayscale(100%); 
 
filter: grayscale(100%); 
 
} 
 
50% { 
 
    filter: grayscale(90%); 
 
-webkit-filter: grayscale(100%); 
 
-moz-filter: grayscale(100%); 
 
-moz-filter: grayscale(100%); 
 
filter: grayscale(100%); 
 
} 
 
60% { 
 
    filter: brightness(10%); 
 
-webkit-filter: grayscale(100%); 
 
-moz-filter: grayscale(100%); 
 
-moz-filter: grayscale(100%); 
 
filter: grayscale(100%); 
 
} 
 
70% { 
 
    filter: brightness(30%); 
 
-webkit-filter: grayscale(100%); 
 
-moz-filter: grayscale(100%); 
 
-moz-filter: grayscale(100%); 
 
filter: grayscale(100%); 
 
} 
 
80% { 
 
    filter: brightness(20%); 
 
} 
 
90% { 
 
    filter: brightness(40%); 
 
} 
 
100% { 
 
    filter: brightness(90%); 
 
} 
 
}
<!DOCTYPE html> 
 
<html lang="en"> 
 
<head> 
 
<meta charset="UTF-8"> 
 
<link rel="stylesheet" href="css/style.css"> 
 
<title>Document</title> 
 
</head> 
 
<body> 
 

 
<div id="container"> 
 
<div id="vrouw"></div> 
 
<div id="hoofd"></div> 
 
<div id="berg"></div> 
 
</div> 
 

 

 
</body> 
 
</html>

+0

それは動作していません;)、私は私の山のイメージ上にホバーを置くと、私は欲しい色に透明なものを着色すると言う画像そのもの。私はキーフレームで画像を拡大/縮小できますが、グレースケールにしたいときは機能しません。 – Sid

+0

グレースケールを使用したキーフレームがほとんどないデモを追加しました。あなたのような人が簡単に答えを見つけることができるように、それが役に立ったら答えとして受け入れてください。 – jafarbtech

+0

グレースケールを(huufd)ではなく(bergk)に置いてください;)あなたのコードは正しくありません;) – Sid

0

私は今、これを試すことはできませんが、あなたは、このコード

img { 
-webkit-filter: grayscale(100%); /* Safari 6.0 - 9.0 */ 
filter: grayscale(100%); 
} 
関連する問題