--- id: 5a90374338fddaf9a66b5d3a title: 使用 justify-self 水平對齊項目 challengeType: 0 videoUrl: 'https://scrimba.com/p/pByETK/cJbpKHq' forumTopicId: 301122 dashedName: align-an-item-horizontally-using-justify-self --- # --description-- 在 CSS 網格中,每個網格項的內容分別位於被稱爲單元格(cell)的框內。 你可以使用網格項的 `justify-self` 屬性,設置其內容的位置在單元格內沿水平軸的對齊方式。 默認情況下,這個屬性的值是 `stretch`,這將使內容佔滿整個單元格的寬度。 該 CSS 網格屬性也可以使用其他的值: `start`:使內容在單元格左側對齊, `center`:使內容在單元格居中對齊, `end`:使內容在單元格右側對齊, # --instructions-- 請使用 `justify-self` 屬性讓 class 爲 `item2` 的網格項居中。 # --hints-- class 爲 `item2` 的元素應具有 `justify-self` 屬性且屬性值應爲 `center`。 ```js assert( code.match(/.item2\s*?{[\s\S]*justify-self\s*?:\s*?center\s*?;[\s\S]*}/gi) ); ``` # --seed-- ## --seed-contents-- ```html