--- id: bad87fee1348cd8acef08812 title: 创建一个 Bootstrap 块级元素按钮 challengeType: 0 forumTopicId: 16810 dashedName: create-a-block-element-bootstrap-button --- # --description-- 一般情况下,`btn` 和 `btn-default` 两个 classes 修饰的 `button` 元素宽度与它包含的文本相同, 举个例子: ```html Submit ``` 这个按钮的宽度应该和文本 `Submit` 的宽度相同。 提交 通过为按钮添加 class 属性 `btn-block` 使其成为块级元素,按钮会伸展并填满页面的整个水平空间,后续的元素会流到这个块级元素的下方,即 "另起一行"。 ```html Submit ``` 这个按钮会 100% 占满所有的可用宽度。 提交 注意,这些按钮仍然需要 `btn` 这个 class。 给刚创建的 Bootstrap 按钮添加 Bootstrap 的 `btn-block` class。 # --hints-- 按钮仍然应该有 `btn` 和 `btn-default` class。 ```js assert($('button').hasClass('btn') && $('button').hasClass('btn-default')); ``` 按钮应该有 `btn-block` class。 ```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: