2021-06-15 00:49:18 -07:00
---
id: bad88fee1348ce8acef08815
2021-07-16 11:03:16 +05:30
title: Use a Grid Bootstrap para Colocar Elementos Lado a Lado
2021-06-15 00:49:18 -07:00
challengeType: 0
forumTopicId: 18371
dashedName: use-the-bootstrap-grid-to-put-elements-side-by-side
---
# --description--
2021-07-16 11:03:16 +05:30
Bootstrap usa o sistema responsivo de grid de 12 colunas, o que torna super fácil colocar elementos em linhas e especificar cada largura relativa de um elemento. A maioria das classes Bootstrap podem ser aplicadas a um elemento `div` .
2021-06-15 00:49:18 -07:00
2021-07-16 11:03:16 +05:30
Bootstrap possui diferentes atributos de largura de colunas que utiliza dependendo do quão largo for a tela do usuário. Por exemplo, celulares possuem telas estreitas, e laptops possuem telas mais largas.
2021-06-15 00:49:18 -07:00
2021-07-16 11:03:16 +05:30
Tome como exemplo a classe Bootstrap `col-md-*` . Aqui, `md` significa médio, e `*` é o número especificando quantas colunas de largura o elemento deve ser. Nesse caso, a largura da coluna de um elemento em uma tela de tamanho mediano, como um laptop, está sendo especificado.
2021-06-15 00:49:18 -07:00
2021-07-16 11:03:16 +05:30
No app de Foto de Gatos que estamos construindo, utilizaremos `col-xs-*` , onde `xs` significa extra pequeno (como uma tela extra pequena de um telefone móvel), e `*` é o número de colunas especificando quantas colunas de largura o elemento deve ser.
2021-06-15 00:49:18 -07:00
2021-07-16 11:03:16 +05:30
Coloque os botões `Like` , `Info` e `Delete` lado a lado ao aninhar todos os três em um elemento `<div class="row">` , em seguida, cada um deles dentro de um elemento `<div class="col-xs-4">` .
2021-06-15 00:49:18 -07:00
2021-07-16 11:03:16 +05:30
A classe `row` é aplicada à `div` , e os próprios botões podem ser aninhados dentro dela.
2021-06-15 00:49:18 -07:00
# --hints--
2021-07-16 11:03:16 +05:30
Seu botões devem estar aninhados dentro do mesmo elemento `div` com a classe `row` .
2021-06-15 00:49:18 -07:00
```js
assert($('div.row:has(button)').length > 0);
```
2021-07-16 11:03:16 +05:30
Cada um dos seus botões Bootstrap devem estar aninhados dentro de seu próprio elemento `div` com a classe `col-xs-4` .
2021-06-15 00:49:18 -07:00
```js
assert($('div.col-xs-4:has(button)').length > 2);
```
2021-07-16 11:03:16 +05:30
Cada um dos seus elementos `button` devem ter uma tag de fechamento.
2021-06-15 00:49:18 -07:00
```js
assert(
code.match(/< \/button > /g) &&
code.match(/< button / g ) & &
code.match(/< \/button > /g).length === code.match(/< button / g ). length
);
```
2021-07-16 11:03:16 +05:30
Cada um dos seus elementos `div` devem ter uma tag de fechamento.
2021-06-15 00:49:18 -07:00
```js
assert(
code.match(/< \/div > /g) &&
code.match(/< div / g ) & &
code.match(/< \/div > /g).length === code.match(/< div / 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://bit.ly/fcc-relaxing-cat" alt = "A cute orange cat lying on its back." > < / a >
< img src = "https://bit.ly/fcc-running-cats" class = "img-responsive" alt = "Three kittens running towards the camera." >
< button class = "btn btn-block btn-primary" > Like< / button >
< button class = "btn btn-block btn-info" > Info< / button >
< button class = "btn btn-block btn-danger" > Delete< / 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://bit.ly/fcc-relaxing-cat" alt = "A cute orange cat lying on its back." > < / a >
< img src = "https://bit.ly/fcc-running-cats" class = "img-responsive" alt = "Three kittens running towards the camera." >
< div class = "row" >
< div class = "col-xs-4" >
< button class = "btn btn-block btn-primary" > Like< / button >
< / div >
< div class = "col-xs-4" >
< button class = "btn btn-block btn-info" > Info< / button >
< / div >
< div class = "col-xs-4" >
< button class = "btn btn-block btn-danger" > Delete< / button >
< / div >
< / div >
2021-07-09 21:23:54 -07:00
2021-06-15 00:49:18 -07:00
< 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 >
```