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

标签 html css dropshadow

我已经为复选框的标签添加了阴影,这样当它们被选中时,阴影就会出现。它们在 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 的 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/

相关文章:

html - 带框阴影的 CSS 语音气泡

android - android中的背景阴影

javascript - 按每隔一行对表进行排序

删除选择列表的Javascript循环限制不断变化

html - 如何禁用 CSS 中的定向焦点导航

css - 如何在 jQuery Mobile 中定位按钮

css - 如何通过在 css 文件中应用 hue change co 所有颜色来更改 css 配色方案

javascript - jQuery fadeOut 和 fadeIn 背景图像

css - 如何在 png 图像上制作圆形阴影

html - 两个或多个 div 宽度为父级的 100%