颜色是固定的White color icon.png to blue color icon.png (html/css),但是最小值(或最大值)怎么办?
div {
width: 50px;
height: 50px;
margin: 50px;
padding: 50px;
top: 50px;
bottom: 50px;
left: 50px;
right: 50px;
background-size: 50px;
mask-size: 50px; /* not supported by Chrome */
-webkit-mask-image: 50px; /* also not supported by Chrome */
background-color: blue; /* select your want color */
-webkit-mask-image:
url(https://image.flaticon.com/icons/png/512/54/54591.png);
mask-image: url(https://image.flaticon.com/icons/png/512/54/54591.png);
mask-repeat:no-repeat;
-webkit-mask-repeat:no-repeat;
}
<div></div>
如何缩小尺寸?
margin: 50px; padding: 50px;
否
left: 50px; right: 50px; top: 50px; bottom: 50px;
否
background-size: 50px;
否
mask-size: 50px;
否,Chrome不支持
webkit-mask-size: 50px;
否,Chrome也不支持
width: 50px; height: 50px;
没有
该怎么办?
答案 0 :(得分:0)
您可以依靠mix-blend-mode
而不是蒙版,然后轻松地将图像调整为简单的背景:
div.box {
width: 50px;
height: 50px;
padding: 50px;
background: url(https://image.flaticon.com/icons/png/512/54/54591.png) center/cover;
position: relative;
background-color: #fff;
}
div.box:before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: blue;
mix-blend-mode: lighten;
}
<div class="box"></div>
您还可以通过调整伪元素来更改图像的一部分颜色:
div.box {
width: 150px;
height: 150px;
background: url(https://image.flaticon.com/icons/png/512/54/54591.png) center/cover;
position: relative;
background-color: #fff;
}
div.box:before {
content: "";
position: absolute;
top: 20%;
left: 20%;
right: 20%;
bottom: 20%;
background: blue;
mix-blend-mode: lighten;
}
<div class="box"></div>