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

83 lines
1.6 KiB
Markdown

---
id: 60a3e3396c7b40068ad6997f
title: 步驟 22
challengeType: 0
dashedName: step-22
---
# --description--
在畫布的頂部、底部、左側和右側添加 1 個像素的填充將其尺寸更改爲 502 像素 x 602 像素。
`padding` 屬性替換爲 `overflow` 設置爲 `hidden` - 將畫布更改回其原始尺寸。
# --hints--
應該從 `.canvas` 選擇器中刪除 `padding` 屬性。
```js
const canvasPadding = new __helpers.CSSHelp(document).getStyle('.canvas').getPropertyValue('padding');
assert(!canvasPadding);
```
應該將 `overflow` 屬性設置爲 `hidden`
```js
const hasOverflow = new __helpers.CSSHelp(document).getCSSRules().some(x => x.style.overflow === 'hidden');
assert(hasOverflow);
```
`.canvas` 元素的 `overflow` 值應爲 `hidden`
```js
const canvasOverflow = new __helpers.CSSHelp(document).getStyle('.canvas')?.getPropertyValue('overflow');
assert(canvasOverflow === 'hidden')
```
# --seed--
## --seed-contents--
```css
.canvas {
width: 500px;
height: 600px;
background-color: #4d0f00;
--fcc-editable-region--
padding: 1px;
--fcc-editable-region--
}
.frame {
border: 50px solid black;
width: 500px;
padding: 50px;
margin: 20px auto;
}
.one {
width: 425px;
height: 150px;
background-color: #efb762;
margin: 20px auto;
}
```
```html
<!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">
<div class="one"></div>
</div>
</div>
</body>
</html>
```