배경 이미지가있는 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를 피하고 싶습니다.