create a graphic using css - zilongxuan001/LearnFreecode GitHub Wiki

利用CSS制图

理解

使用多个选择器和属性,你可以创作很多有趣的图。 一个很简单的方法是制作一个新月。

对于这个挑战,你需要使用box-shadow属性,来设置一个元素的阴影,再设置border-radius控制元素的圆角。

你可以创造一个圆,然后使用轻移到边上的脆影(crisp shadow)来变形物体,这个阴影就会变成月亮的形状。

为了创造一个圆形物体,border-radius的属性应该设置为50%。

你可以使用box-shadow属性的offset--xoffset-yblur-radiusspread-radius和color。其中blur-radiusspread-radius值是可选的。

练习

在编辑器操纵方块元素变成月亮形状。首先,改变background-color为透明的,设置border-radius的属性为50%来创造圆形。最后,改变box-shadow属性,设置offset-x为25px,offset-y为10px,blur-radius为0,spread-raius为0,color为blue。

<style>
.center
{
  position: absolute;
  margin: auto;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100px;
  height: 100px;
  
  background-color: transparent;
  border-radius: 50%;
  box-shadow: 25px 10px 0 0 blue; 
}

</style>
<div class="center"></div>

来源

Editing create a graphic using css · zilongxuan001/LearnFreecode Wiki

CHANGELOG

2018-10-31 10:18:35

⚠️ **GitHub.com Fallback** ⚠️