freeCodeCamp/curriculum/challenges/chinese-traditional/14-responsive-web-design-22/learn-the-css-box-model-by-.../60a3e3396c7b40068ad69979.md

1.2 KiB

id title challengeType dashedName
60a3e3396c7b40068ad69979 步驟 16 0 step-16

--description--

.canvas 元素內添加一個新的 div 元素。

爲新的 div 賦予 class 屬性,其值爲 one。 這是你的第一個矩形。

--hints--

應該創建一個新的 div 元素。

assert(document.querySelectorAll('div').length === 3);

應該將新的 div 元素嵌套在 .canvas 元素中。

assert(document.querySelector('.canvas').children[0].tagName === 'DIV');

新的 div 應該有一個 class 屬性,其值爲 one

assert(document.querySelector('.canvas').children[0].className.split(' ').includes('one'));

--seed--

--seed-contents--

.canvas {
  width: 500px;
  height: 600px;
  background-color: #4d0f00;
}

.frame {
  border: 50px solid black;
  width: 500px;
  padding: 50px;
  margin: 20px auto;
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Rothko Painting</title>
    <link href="./styles.css" rel="stylesheet">
  </head>
  <body>
    <div class="frame">
      <div class="canvas">
--fcc-editable-region--

--fcc-editable-region--
      </div>
    </div>
  </body>
</html>