私は背景画像を持つdivを持っています。白黒で表示するフィルタを使用しています(filter: grayscale(100%);
)。私は今、そのdivの中に色のアイコンを配置しようとしています。アイコンをgrayscale(0%)
に設定しようとしましたが、これは機能していません。グレースケール(100%)コンテナ内のカラー画像
#a1, #a2 {
background-image: url(http://ndrichardson.com/blog/wp-content/uploads/2012/04/colorpsychology.jpg);
background-repeat: no-repeat;
background-size: 100% 100%;
}
#a1 {
height: 250px;
width: 250px;
-webkit-filter: grayscale(100%);
filter: grayscale(100%);
position: relative;
}
#a2 {
height: 50px;
width: 50px;
-webkit-filter: grayscale(0%);
filter: grayscale(0%);
position: absolute;
top: 0px;
right: 0px;
}
<div id="a1"><!-- << this should be black and white -->
<div id="a2"><!-- << this should be color -->
</div>
</div>
背景画像を保持するために、追加のdivを作成せずにこれを行う方法があります:ここで
は一例ですか?実際のコードははるかに複雑なので、可能であれば余分なdivを避けたいのです。