freeCodeCamp/curriculum/challenges/chinese/01-responsive-web-design/applied-visual-design/create-a-graphic-using-css....

2.9 KiB
Raw Blame History

id title challengeType videoUrl localeTitle
587d78a6367417b2b2512add Create a Graphic Using CSS 0 使用CSS创建图形

Description

通过操纵不同的选择器和属性,您可以制作有趣的形状。其中一个更容易尝试的是月牙形状。对于此挑战,您需要使用设置元素box-shadowbox-shadow属性,以及控制元素角落圆度的border-radius属性。您将创建一个圆形透明对象,其阴影略微偏向侧面 - 阴影实际上将是您看到的月亮形状。要创建圆形对象, border-radius属性应设置为50的值。您可以从之前的挑战中回想一下 box-shadow属性采用offset-x offset-y blur-radius spread-radius和颜色值的值。 blur-radiusspread-radius值是可选的。

Instructions

在编辑器中操纵方形元素以创建月亮形状。首先,将background-color更改为透明,然后将border-radius属性设置为50以生成圆形。最后更改box-shadow属性,将offset-x设置为25px offset-y为10px blur-radius为0 spread-radius为0颜色设置为蓝色。

Tests

tests:
  - text: <code>background-color</code>属性的值应设置为<code>transparent</code> 。
    testString: 'assert(code.match(/background-color:\s*?transparent;/gi), "The value of the <code>background-color</code> property should be set to <code>transparent</code>.");'
  - text: <code>border-radius</code>属性的值应设置为<code>50%</code> 。
    testString: 'assert(code.match(/border-radius:\s*?50%;/gi), "The value of the <code>border-radius</code> property should be set to <code>50%</code>.");'
  - text: <code>box-shadow</code>属性的值应设置为<code>offset-x</code>为25px <code>offset-y</code>为10px <code>blur-radius</code>为0 <code>spread-radius</code>为0最后为颜色为蓝色。
    testString: 'assert(code.match(/box-shadow:\s*?25px\s+?10px\s+?0(px)?\s+?0(px)?\s+?blue\s*?;/gi), "The value of the <code>box-shadow</code> property should be set to 25px for <code>offset-x</code>, 10px for <code>offset-y</code>, 0 for <code>blur-radius</code>, 0 for <code>spread-radius</code>, and finally blue for the color.");'

Challenge Seed

<style>
.center
{
  position: absolute;
  margin: auto;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100px;
  height: 100px;

  background-color: blue;
  border-radius: 0px;
  box-shadow: 25px 10px 10px 10px green;
}

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

Solution

// solution required