我已经为复选框的标签添加了阴影,这样当它们被选中时,阴影就会出现。它们在 chrome 上完美运行,但是当我在我的 mac 和 iPhone 上的 safari 上尝试它们时,投影没有出现。我曾尝试使用 -webkit-filter CSS,但这没有任何效果。
我在下面包含了 HTML 和 CSS。
<li>
<input type="checkbox" id="dairy" name="lifestyle" value="dairy-">
<label for="dairy">
<img src="https://cdn.shopify.com/s/files/1/0433/2958/5306/files/Cheese_Icon.png?v=1611093331" class="choose--contents--img" alt="">
<p>Dairy</p>
</label>
</li>
label {
display: flex;
flex-direction: column;
align-items: center;
border: 1px solid #5E7735;
background-color: white;
border-radius: 8px;
width: 117.5px;
height: 140px;
box-sizing: border-box;
cursor: pointer;
}
:checked + label {
filter: drop-shadow(6px 6px 0 #5E7735);
-webkit-filter: drop-shadow(6px 6px 0 #5E7735);
-moz-filter: drop-shadow(6px 6px 0 #5E7735);
-ms-filter: drop-shadow(6px 6px 0 #5E7735);
-o-filter: drop-shadow(6px 6px 0 #5E7735);
transition: filter 0.1s ease-in;
-webkit-transition: filter 0.1s ease-in;
}
它们应该是这样的
但是他们看起来是这样的(阴影被剪掉了)
最佳答案
当我玩这个时,我认为一种解决方案是使用框阴影,并应用使用 vw 的 border-radius,以实现比例。
像这样:
.class {
box-shadow: 6px 6px 0 #5E7735;
border-radius: 5vw; /* Or whatever fits the corners of the image used) */
}
这是一种解决方法,但希望它可以帮助那里的人!
关于html - 阴影在 iOS Safari 上无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65801487/