2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
id: 587d7791367417b2b2512ab5
|
2020-12-16 00:37:30 -07:00
|
|
|
|
title: 使用 height 属性调整元素的宽度
|
2018-10-10 18:03:03 -04:00
|
|
|
|
challengeType: 0
|
2020-02-11 15:46:34 +08:00
|
|
|
|
videoUrl: 'https://scrimba.com/c/cEDaDTN'
|
|
|
|
|
forumTopicId: 301034
|
2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
# --description--
|
|
|
|
|
|
|
|
|
|
和 `width` 属性类似,你可以使用 CSS 里面的 `height` 属性来指定元素的高度。下面这个例子把图片的高度设置为 20px:
|
2020-02-11 15:46:34 +08:00
|
|
|
|
|
|
|
|
|
```css
|
|
|
|
|
img {
|
|
|
|
|
height: 20px;
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
# --instructions--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
给 `h4` 标签添加 `height` 属性并设置值为 25px。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
**注意:** 可能需要将浏览器的缩放比调整为 100% 才能通过这一挑战。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
# --hints--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
你应该设置 `h4` 的 `height` 属性,使其值为 `25px`。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
```js
|
|
|
|
|
assert(
|
|
|
|
|
Math.round(document.querySelector('h4').getBoundingClientRect().height) ===
|
|
|
|
|
25 &&
|
|
|
|
|
/h4{\S*height:25px(;\S*}|})/.test($('style').text().replace(/\s/g, ''))
|
|
|
|
|
);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
```
|
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
# --solutions--
|
2020-02-11 15:46:34 +08:00
|
|
|
|
|