css - 圆 Angular 盒阴影仅在 Angular 落处

标签 css

我希望框阴影仅出现在圆形的 Angular 处。 但盒子阴影出现在所有侧面。我想要如下图所示的东西。

enter image description here

html:

<div class="img">
    <img src="http://www.html5andbeyond.com/3t-JAiBqopF/uploads/2014/10/clouds-full.png" alt=""/>
</div>

CSS:

img {
    -webkit-box-shadow: 0 15px 10px #777;
    -moz-box-shadow: 0 15px 10px #777;
    box-shadow: 0 15px 10px #777;
}

最佳答案

不完全是,但你的问题可以通过它来解决。

html

<div class="shadow">
  <div class="img">
    <img src="http://placehold.it/250x300" alt="" />
  </div>
</div>

CSS

*{
box-sizing: border-box;
}
.shadow {
  width: 250px;
  height: 300px;
  position: relative;
  margin: auto;
}

.img {
  padding: 15px;
  background: #fff;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

.shadow {
  position: relative;
}

.shadow:after,
.shadow:before,
.img:after,
.img:before{
    content: "";
    width: 50px;
    height: 50px;
    box-shadow: 0px 0px 26px rgba(0, 0, 0, 0.6);
    position: absolute;
    z-index: -1;
}

.shadow:before,
.shadow:after{
  top: 0;
}
.img:before, .img:after {
    bottom: 6px;
}
.shadow:before{
  left: 0;
}
.shadow:after {
  right: 0;
}
.img:before {
  left: 0;
}

.img:after {
  right: 0;
}

参见Fiddle

关于css - 圆 Angular 盒阴影仅在 Angular 落处,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36762956/

相关文章:

javascript - 一个链接到多个容器 anchor

css - 通过 css 为 javafx.scene.text.Text 设置文本

javascript - Angular ,鼠标悬停速度不稳定?

css - 这些 CSS 片段中的哪一个更有效地实现了预期的结果?

html - 在 firefox 上使用 font-face

javascript - 如何在javascript中更改鱼眼效果中元素之间的边距

HTML & CSS - 将对象移动到特定位置

html - Bootstrap4 中的对齐问题

css - Font Awesome : Why isn't my arrow icon loading on an :after instance?

javascript - 在 JS 中更改类属性 - 更好的性能