--- id: 587d7791367417b2b2512ab4 title: 使用 width 屬性調整元素的寬度 challengeType: 0 videoUrl: 'https://scrimba.com/c/cvVLPtN' forumTopicId: 301039 dashedName: adjust-the-width-of-an-element-using-the-width-property --- # --description-- 你可以使用 CSS 裏的 `width` 屬性來指定元素的寬度。 屬性值可以是相對單位(比如 `em`),絕對單位(比如 `px`),或者包含塊(父元素)寬度的百分比。 下面這段代碼可以把圖片的寬度設置爲 220px: ```css img { width: 220px; } ``` # --instructions-- 爲卡片元素添加 `width` 屬性,並將它的寬度設置爲 245px。 使用 `fullCard` class 來選擇卡片元素。 # --hints-- 應使用 `fullCard` class 選擇器將卡片的 `width` 屬性值設置爲 `245px`。 ```js const fullCard = code.match(/\.fullCard\s*{[\s\S]+?[^}]}/g); assert( fullCard && /width\s*:\s*245px\s*(;|})/gi.test(fullCard[0]) && $('.fullCard').css('maxWidth') === 'none' ); ``` # --seed-- ## --seed-contents-- ```html
Google was founded by Larry Page and Sergey Brin while they were Ph.D. students at Stanford University.
Google was founded by Larry Page and Sergey Brin while they were Ph.D. students at Stanford University.