5

这是我想用 HTML/CSS 重新创建的图像:

在此处输入图像描述

中心渐变很简单,两个环也是如此(中心周围有一个边框,该 div 周围有一个 div,它有自己的边框)。左边的外部阴影似乎也很简单。

这是迄今为止我最好的近似值(带有匹配的小提琴):

  <div id="youedge">
    <div id="youlight" class="round border radialgradientbg">                
    </div>
  </div>

#youedge {
    border:30px solid #888;
    border-radius:190px;
    width:190px;height:190px;margin:50px;
    box-shadow:-30px 0 0 #555;
}

    #youlight { width:150px; height:150px; background-color:#2b0c0f; }
    .round { border-radius:190px; }
    .border { border:20px solid #777; }
    body { background-color:#999; }

    .radialgradientbg {
    background: -moz-radial-gradient(center, ellipse cover,  #4c1113 0%, #16040a 100%); /* FF3.6+ */
    background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,#4c1113), color-stop(100%,#16040a)); /* Chrome,Safari4+ */
    background: -webkit-radial-gradient(center, ellipse cover,  #4c1113 0%,#16040a 100%); /* Chrome10+,Safari5.1+ */
    } 

我想不通的是中心周围两个灰色边框上的 3D 照明效果。有没有办法在 CSS 中实现这一点?

4

1 回答 1

6

您可以使用单个元素并使用:beforeand:after以及linear-gradientand box-shadow..

这个想法是在具有相反线性渐变背景的主要元素后面放置两个圆圈。

.circle-3d {
  position: relative;
  width: 150px;
  height: 150px;
  background: black;
  border-radius: 50%;
  margin:2em;
}

.circle-3d:before {
  position: absolute;
  content: '';
  left: -20px;
  top: -20px;
  bottom: -20px;
  right: -20px;
  background: linear-gradient(90deg, #666, #ccc);
  border-radius: 50%;
  z-index: -2;
  box-shadow: -20px 0 10px -5px #000;
}

.circle-3d:after {
  position: absolute;
  left: -10px;
  top: -10px;
  bottom: -10px;
  right: -10px;
  background: linear-gradient(270deg, #222, #eee);
  content: '';
  border-radius: 50%;
  z-index: -1;
}
<div class="circle-3d"></div>

于 2013-11-10T11:25:12.790 回答