html - 制作 CSS 过滤器 : drop-shadow() goes through others elements

标签 html css

我想让 filter: drop-shadow() 遍历其他元素。这可能听起来令人困惑,让我用一张图片来解释一下。

this is an image

<div class="h-100">
    <img src="___.svg"/>
</div>
<div class="h-100">
    <img src="___.svg"/>
</div>
<div class="h-100">
    <img src="___.svg"/>
</div>
img {
    -webkit-filter: drop-shadow(0px 0px 150px rgba(255, 255, 209, 1));
    filter: drop-shadow(0px 0px 150px rgba(255, 255, 209, 1));

    /* Centering the svg */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/*From bootstrap*/
.h-100 {
    height: 100% !important;
}

最佳答案

你可以使用这个代码

body {
  margin: 0;
}

img {
  filter: drop-shadow(0 0 30px rgba(255, 255, 209, 1));
  width: 100px;
  height: 100px;
  border-radius: 100%;
  background: yellow;
  border: none;
}

.h-100 {
  width: 15%;
  display: inline-block;
  text-align: center;
  background: black;
  padding: 150px 20px;
}
<div class="container">
  <div class="h-100">
    <img src="https://images.unsplash.com/photo-1546948630-1149ea60dc86?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1500&q=80" />
  </div>
  <div class="h-100">
    <img src="https://images.unsplash.com/photo-1546948630-1149ea60dc86?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1500&q=80" />
  </div>
  <div class="h-100">
    <img src="https://images.unsplash.com/photo-1546948630-1149ea60dc86?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1500&q=80" />
  </div>
</div>

关于html - 制作 CSS 过滤器 : drop-shadow() goes through others elements,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58464511/

相关文章:

python - 火星 2020 网页抓取

javascript - 如何使用 js/jquery 拆分 <p> 列表?

javascript - react native : How to set <TextInput/>'s height and width to <View/> container?

javascript - 如何使用javascript在html页面中连续获取移动物体的位置?

html - 使用开放图在 Facebook 上共享音频

javascript - 我如何让 DOM 知道动态创建的新元素?

javascript - 从隐藏元素获取宽度大小

c# - UWP Visual C# WebView InvokeScript 更改 CSS 抛出异常

HTML div 宽度和文本框宽度不相等

javascript - 宽度为 100% 的可扩展/可收缩列