--- id: bad87fee1348bd9bedf08813 title: 在元素周圍添加邊框 challengeType: 0 videoUrl: 'https://scrimba.com/c/c2MvnHZ' forumTopicId: 16630 dashedName: add-borders-around-your-elements --- # --description-- CSS 邊框具有 `style`、`color`、`width` 屬性。 假如我們要將一個 HTML 元素邊框設置爲 5px 的紅色實線邊框,我們可以這樣做: ```html ``` # --instructions-- 創建一個名爲 `thick-green-border` 的 class, 該 class 應在 HTML 元素周圍添加一個 10px 的綠色實線邊框。 將這個 class 應用於你的貓圖。 記得在一個元素上可以同時應用多個 `class`,使用空格來分隔不同 class 即可, 例如: ```html ``` # --hints-- `img` 元素的 class 應包含 `smaller-image`。 ```js assert($('img').hasClass('smaller-image')); ``` `img` 元素應包含 `thick-green-border` class。 ```js assert($('img').hasClass('thick-green-border')); ``` 圖片邊框寬度應設置爲 `10px`。 ```js assert( $('img').hasClass('thick-green-border') && parseInt($('img').css('border-top-width'), 10) >= 8 && parseInt($('img').css('border-top-width'), 10) <= 12 ); ``` 圖片邊框樣式應爲 `solid` 實線。 ```js assert($('img').css('border-right-style') === 'solid'); ``` `img` 元素的邊框顏色應爲綠色。 ```js assert($('img').css('border-left-color') === 'rgb(0, 128, 0)'); ``` # --seed-- ## --seed-contents-- ```html

CatPhotoApp

Click here to view more cat photos.

A cute orange cat lying on its back.

Things cats love:

Top 3 things cats hate:

  1. flea treatment
  2. thunder
  3. other cats


``` # --solutions-- ```html

CatPhotoApp

Click here to view more cat photos.

A cute orange cat lying on its back.

Things cats love:

Top 3 things cats hate:

  1. flea treatment
  2. thunder
  3. other cats


```