css - 使用 CSS 在图像上添加 3D 效果

标签 css css-shapes

我想在纯 CSS 的帮助下添加一个 3D 效果,我想转换这个图像:

enter image description here

(它不是真正的图像,而是用 <fa-icon icon="undo" mask="circle" transform="shrink-9"></fa-icon> 渲染的 SVG 形式的 FontAwesome )

到这张图片:

enter image description here

但我无法获得确切的效果。我尝试了一些 CSS 技巧,但我坚持使用以下输出:

enter image description here

我写的SASS是:

.three-d-effect {
    position: relative;

    &:after {
        content: "";
        position: absolute;
        top: 5%;
        left: 10%;
        width: 80%;
        height: 80%;
        border-radius: 100%;
        filter: blur(1px);
        z-index: 2;
        transform: rotateZ(40deg);
        display: block;
        background: radial-gradient(circle at 50% 80%, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0) 74%, white 80%, white 84%, rgba(255, 255, 255, 0) 100%);
    }
}

是否可以通过 CSS 实现想要的 3D 效果?

最佳答案

这是我的尝试,我还使用 CSS 创建了箭头:

.box {
  width: 100px;
  height: 100px;
  background: 
   url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64' width='30' height='30'  fill='lightpink'>  <path d='M6 22 L5.84 22 C30 32 36 36 54 60 C56 62 57 62 56 58 C48 34 46 28 27.16 11.17 C10 0 0 17.83 6 22.17 Z' /></svg>") 65px 10px/30px 30px no-repeat,
   radial-gradient(circle at center,#ff4290 20%,transparent 50%),
   radial-gradient(circle at top right,#ff97c2 15%,#ff5d9f 50%,#c4326e 65%);
  border-radius: 50%;
  position: relative;
  box-shadow:0 0 1px #c4326e;
  filter: brightness(110%);
}

.box:before {
  content: "";
  position: absolute;
  top: 25px;
  left: 25px;
  right: 25px;
  bottom: 25px;
  border: 6px solid white;
  border-left-color: transparent;
  border-radius: 50%;
}

.box:after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  background: 
   linear-gradient(#fff, #fff) left/6px 100% no-repeat, 
   linear-gradient(#fff, #fff) bottom/100% 6px no-repeat;
  top: 22px;
  left: 29px;
}
<div class="box">

</div>

关于css - 使用 CSS 在图像上添加 3D 效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51847370/

相关文章:

css - 如何自定义 ionic 风格的组件(不同形状的列表和标签)

css - 如何在 CSS 中创建不同 Angular 包装器

html - 使用 css3 创建 Logo

html - 在 chrome 中带有溢出自动的框布局

html - 圆形按钮上的斜 Angular

css - 动态调整单个形状的大小而不缩放整个 SVG

ios - 仅在 iPad 纵向上将 Bootstrap 导航栏元素居中?

css - 无法弄清楚背景图像 : url();

javascript - .slideDown() 下面的内容跳转(不流畅)

css - 如何定位我的 wordpress 网站上的一个特定页面以显示响应式布局?