mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-04-13 22:00:19 -04:00
186 lines
5.1 KiB
Markdown
186 lines
5.1 KiB
Markdown
---
|
|
id: bad87fee1348cd8acef08812
|
|
title: 부트스트랩 버튼을 블록 레벨 요소로 만들기
|
|
challengeType: 0
|
|
forumTopicId: 16810
|
|
dashedName: create-a-block-element-bootstrap-button
|
|
---
|
|
|
|
# --description--
|
|
|
|
일반적으로 `btn`클래스와 `btn-default` 클래스가 적용된 `button` 요소는, 버튼 안에 담겨진 텍스트 길이만큼의 너비를 차지합니다. 예를 들어:
|
|
|
|
```html
|
|
<button class="btn btn-default">Submit</button>
|
|
```
|
|
|
|
이 버튼은 `Submit`이라는 단어만큼의 너비만을 차지합니다.
|
|
|
|
<button class='btn btn-default'>Submit</button>
|
|
|
|
`btn-block`이라는 클래스를 버튼 요소에 추가해줌으로써 버튼을 블록 레벨 요소로 만들 수 있습니다. 버튼은 페이지의 가로 공간을 꽉 채워 차지하게 됩니다. 버튼 뒤에 나오는 요소들은, 버튼 아래의 새로운 줄에 배치됩니다.
|
|
|
|
```html
|
|
<button class="btn btn-default btn-block">Submit</button>
|
|
```
|
|
|
|
이 버튼은 사용 가능한 너비의 100%를 차지할 것입니다.
|
|
|
|
<button class='btn btn-default btn-block'>Submit</button>
|
|
|
|
버튼에는 여전히 `btn` 클래스가 있어야 합니다.
|
|
|
|
부트스트랩 버튼에 `btn-block` 클래스를 추가해보세요.
|
|
|
|
# --hints--
|
|
|
|
버튼에는 여전히 `btn` 클래스와 `btn-default` 클래스가 있어야 합니다.
|
|
|
|
```js
|
|
assert($('button').hasClass('btn') && $('button').hasClass('btn-default'));
|
|
```
|
|
|
|
버튼에는 `btn-block` 클래스가 있어야 합니다.
|
|
|
|
```js
|
|
assert($('button').hasClass('btn-block'));
|
|
```
|
|
|
|
모든 `button` 요소들에는 닫는 태그가 있어야 합니다.
|
|
|
|
```js
|
|
assert(
|
|
code.match(/<\/button>/g) &&
|
|
code.match(/<button/g) &&
|
|
code.match(/<\/button>/g).length === code.match(/<button/g).length
|
|
);
|
|
```
|
|
|
|
# --seed--
|
|
|
|
## --seed-contents--
|
|
|
|
```html
|
|
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
|
|
<style>
|
|
.red-text {
|
|
color: red;
|
|
}
|
|
|
|
h2 {
|
|
font-family: Lobster, Monospace;
|
|
}
|
|
|
|
p {
|
|
font-size: 16px;
|
|
font-family: Monospace;
|
|
}
|
|
|
|
.thick-green-border {
|
|
border-color: green;
|
|
border-width: 10px;
|
|
border-style: solid;
|
|
border-radius: 50%;
|
|
}
|
|
|
|
.smaller-image {
|
|
width: 100px;
|
|
}
|
|
</style>
|
|
|
|
<div class="container-fluid">
|
|
<h2 class="red-text text-center">CatPhotoApp</h2>
|
|
|
|
<p>Click here for <a href="#">cat photos</a>.</p>
|
|
|
|
<a href="#"><img class="smaller-image thick-green-border" src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
|
|
|
|
<img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/running-cats.jpg" class="img-responsive" alt="Three kittens running towards the camera.">
|
|
<button class="btn btn-default">Like</button>
|
|
<p>Things cats love:</p>
|
|
<ul>
|
|
<li>cat nip</li>
|
|
<li>laser pointers</li>
|
|
<li>lasagna</li>
|
|
</ul>
|
|
<p>Top 3 things cats hate:</p>
|
|
<ol>
|
|
<li>flea treatment</li>
|
|
<li>thunder</li>
|
|
<li>other cats</li>
|
|
</ol>
|
|
<form action="https://freecatphotoapp.com/submit-cat-photo">
|
|
<label><input type="radio" name="indoor-outdoor"> Indoor</label>
|
|
<label><input type="radio" name="indoor-outdoor"> Outdoor</label>
|
|
<label><input type="checkbox" name="personality"> Loving</label>
|
|
<label><input type="checkbox" name="personality"> Lazy</label>
|
|
<label><input type="checkbox" name="personality"> Crazy</label>
|
|
<input type="text" placeholder="cat photo URL" required>
|
|
<button type="submit">Submit</button>
|
|
</form>
|
|
</div>
|
|
```
|
|
|
|
# --solutions--
|
|
|
|
```html
|
|
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
|
|
<style>
|
|
.red-text {
|
|
color: red;
|
|
}
|
|
|
|
h2 {
|
|
font-family: Lobster, Monospace;
|
|
}
|
|
|
|
p {
|
|
font-size: 16px;
|
|
font-family: Monospace;
|
|
}
|
|
|
|
.thick-green-border {
|
|
border-color: green;
|
|
border-width: 10px;
|
|
border-style: solid;
|
|
border-radius: 50%;
|
|
}
|
|
|
|
.smaller-image {
|
|
width: 100px;
|
|
}
|
|
</style>
|
|
|
|
<div class="container-fluid">
|
|
<h2 class="red-text text-center">CatPhotoApp</h2>
|
|
|
|
<p>Click here for <a href="#">cat photos</a>.</p>
|
|
|
|
<a href="#"><img class="smaller-image thick-green-border" src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
|
|
|
|
<img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/running-cats.jpg" class="img-responsive" alt="Three kittens running towards the camera.">
|
|
<button class="btn btn-block btn-default">Like</button>
|
|
<p>Things cats love:</p>
|
|
<ul>
|
|
<li>cat nip</li>
|
|
<li>laser pointers</li>
|
|
<li>lasagna</li>
|
|
</ul>
|
|
<p>Top 3 things cats hate:</p>
|
|
<ol>
|
|
<li>flea treatment</li>
|
|
<li>thunder</li>
|
|
<li>other cats</li>
|
|
</ol>
|
|
<form action="https://freecatphotoapp.com/submit-cat-photo">
|
|
<label><input type="radio" name="indoor-outdoor"> Indoor</label>
|
|
<label><input type="radio" name="indoor-outdoor"> Outdoor</label>
|
|
<label><input type="checkbox" name="personality"> Loving</label>
|
|
<label><input type="checkbox" name="personality"> Lazy</label>
|
|
<label><input type="checkbox" name="personality"> Crazy</label>
|
|
<input type="text" placeholder="cat photo URL" required>
|
|
<button type="submit">Submit</button>
|
|
</form>
|
|
</div>
|
|
```
|