阴影在 iOS Safari 上无法正常工作

问题描述

我为复选框的标签添加了阴影,以便在选中它们时会出现阴影。它们在 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;
}

它们应该是这样的

Example of them from chrome

但它们看起来像这样(阴影被切断了)

Example from Safari

解决方法

当我在玩这个时,我认为一种解决方案可能是使用框阴影,并应用使用 vw 的边界半径,以保持比例。

像这样:

.class {
    box-shadow: 6px 6px 0 #5E7735;
    border-radius: 5vw; /* Or whatever fits the corners of the image used) */
}

这是一种解决方法,但希望它可以帮助那里的人!