--- 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: