2021-06-15 00:49:18 -07:00
---
id: bad87fee1348bd9acde08712
2021-06-26 21:42:30 +05:30
title: Usare il design responsivo con i contenitori fluidi di Bootstrap
2021-06-15 00:49:18 -07:00
challengeType: 0
forumTopicId: 18362
dashedName: use-responsive-design-with-bootstrap-fluid-containers
---
# --description--
2021-06-26 21:42:30 +05:30
Nella sezione HTML5 e CSS di freeCodeCamp abbiamo costruito una Cat Photo App. Ora torniamo ad essa. Questa volta, la stilizzeremo usando il popolare framework CSS responsivo Bootstrap.
2021-06-15 00:49:18 -07:00
2021-06-26 21:42:30 +05:30
Bootstrap capirà quanto è largo lo schermo e risponderà ridimensionando i tuoi elementi HTML - da qui il nome < dfn > design responsivo< / dfn > .
2021-06-15 00:49:18 -07:00
2021-06-26 21:42:30 +05:30
Con un design responsivo, non c'è bisogno di progettare una versione mobile del tuo sito web. Si vedrà bene su dispositivi con schermi di qualsiasi larghezza.
2021-06-15 00:49:18 -07:00
2021-06-26 21:42:30 +05:30
Puoi aggiungere Bootstrap a qualsiasi app inserendo il seguente codice nella parte superiore del tuo HTML:
2021-06-15 00:49:18 -07:00
```html
< link rel = "stylesheet" href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity = "sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin = "anonymous" / >
```
2021-08-20 00:00:51 -07:00
In questo caso, lo abbiamo già aggiunto per te a questa pagina dietro le quinte. Nota che è accettabile usare sia `>` che `/>` per chiudere il tag `link` .
2021-06-15 00:49:18 -07:00
2021-06-26 21:42:30 +05:30
Per iniziare, dovremmo annidare tutto il nostro HTML (tranne il tag `link` e l'elemento `style` ) in un elemento `div` di classe `container-fluid` .
2021-06-15 00:49:18 -07:00
# --hints--
2021-06-26 21:42:30 +05:30
Il tuo elemento `div` dovrebbe avere la classe `container-fluid` .
2021-06-15 00:49:18 -07:00
```js
assert($('div').hasClass('container-fluid'));
```
2021-06-26 21:42:30 +05:30
Il tuo elemento `div` dovrebbe avere un tag di chiusura.
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
);
```
2021-06-26 21:42:30 +05:30
Tutti gli elementi HTML dopo il tag `style` di chiusura dovrebbero essere annidati in un `.container-fluid` .
2021-06-15 00:49:18 -07:00
```js
assert($('.container-fluid').children().length >= 8 & & !$('.container-fluid').has("style").length & & !$('.container-fluid').has("link").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 >
< h2 class = "red-text" > CatPhotoApp< / h2 >
< p > Click here for < a href = "#" > cat photos< / a > .< / p >
2021-09-22 08:34:59 -07:00
< 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 >
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 >
```
# --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" > CatPhotoApp< / h2 >
< p > Click here for < a href = "#" > cat photos< / a > .< / p >
2021-09-22 08:34:59 -07:00
< 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 >
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 >
```