2018-10-10 18:03:03 -04:00
|
|
|
---
|
|
|
|
id: bad87fee1348bd8acde08812
|
2020-12-16 00:37:30 -07:00
|
|
|
title: 用 Bootstrap 居中文本
|
2018-10-10 18:03:03 -04:00
|
|
|
challengeType: 0
|
2020-09-07 16:17:39 +08:00
|
|
|
forumTopicId: 16771
|
2018-10-10 18:03:03 -04:00
|
|
|
---
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --description--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
我们可以使用 Bootstrap 将顶部的元素居中来美化页面。只需要将 `h2` 元素的 class 属性设置为 `text-center` 就可以实现。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
记住:我们通过空格分隔不同的 class 可以为一个元素添加多个 class ,就像这样:
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
`<h2 class="red-text text-center">your text</h2>`
|
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
|
|
|
你的 `h2` 元素应该居中且有一个 class 为 `text-center`
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
```js
|
|
|
|
assert($('h2').hasClass('text-center'));
|
2018-10-10 18:03:03 -04:00
|
|
|
```
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
你的 `h2` 元素应该还有另一个 class 为 `red-text`
|
2020-09-07 16:17:39 +08:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
```js
|
|
|
|
assert($('h2').hasClass('red-text'));
|
2018-10-10 18:03:03 -04:00
|
|
|
```
|
2020-08-13 17:24:35 +02:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --solutions--
|
|
|
|
|