--- id: bad87fee1348cd8acef08812 title: 创建一个 Bootstrap 块级元素按钮 challengeType: 0 forumTopicId: 16810 dashedName: create-a-block-element-bootstrap-button --- # --description-- 一般情况下,`btn` 和 `btn-default` 两个 classes 修饰的 `button` 元素宽度与它包含的文本相同, 举个例子: `Submit` 这个按钮的宽度应该和文本`Submit` 的宽度相同。 提交 通过为按钮添加 class 属性 `btn-block` 使其成为块级元素,按钮会伸展并填满页面整个水平空间,后续的元素会流到这个块级元素的下方,即 "另起一行"。 `Submit` 这个按钮会 100% 占满所有的可用宽度。 提交 记住这些按钮仍然需要 `btn` 这个 class。 添加 Bootstrap 的 `btn-block` class 到刚创建的 Bootstrap 按钮上吧。 # --hints-- 按钮的 class 属性应该仍然包含 `btn` 和 `btn-default`。 ```js assert($('button').hasClass('btn') && $('button').hasClass('btn-default')); ``` 按钮的 class 属性应该包含 `btn-block`。 ```js assert($('button').hasClass('btn-block')); ``` 确保所有的 `button` 元素都有一个闭合标签。 ```js assert( code.match(/<\/button>/g) && code.match(//g).length === code.match(/ CatPhotoApp Click here for cat photos. Like Things cats love: cat nip laser pointers lasagna Top 3 things cats hate: flea treatment thunder other cats Indoor Outdoor Loving Lazy Crazy Submit ``` # --solutions-- ```html CatPhotoApp Click here for cat photos. Like Things cats love: cat nip laser pointers lasagna Top 3 things cats hate: flea treatment thunder other cats Indoor Outdoor Loving Lazy Crazy Submit ```
Click here for cat photos.
Things cats love:
Top 3 things cats hate: