css - 使用 CSS 自定义阴影

标签 css box-shadow

如何根据下图制作阴影?我不知道该怎么做。

A curved shadow

最佳答案

一种方法是将 pesedo 元素 ::before::after 设置为如下样式:

div {
  width: 300px;
  height: 400px;
  background: #FFF;
  margin: 40px auto;
  position: relative;
}

div::before,
div::after {
  z-index: -1;
  position: absolute;
  content: "";
  width: 50%;
  height: 50%;
  right: 10px;
  top: 10px;
  max-width: 300px;
  background: #777;
  box-shadow: 15px 0px 10px #777;
  transform: rotate(3deg);
}

div::after {
  transform: rotate(-3deg);
  top: calc(50% - 10px);
}
<div></div>

这见pen以获得更多阴影样式。

关于css - 使用 CSS 自定义阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58796978/

相关文章:

html - 为什么 Safari 不显示某些框阴影?

Android和box shadow属性

html - CSS 内容 :url is not working in internet explorer 11

javascript - 为什么 document.querySelector 不适用于伪元素?

jquery - 为 details 元素实现 jQuery 回退

jquery - 使用 :after 使用 jquery 更改样式

html - Firefox 中的 CSS 框阴影怪异

css - 内容滚动时框阴影不正确

html - 父div溢出隐藏时如何设置框阴影底部?

javascript - 如何在 jQuery Mobile 中为按钮添加文本颜色