2021-06-15 16:21:20 +02:00
---
id: bad87fee1348bd9acdf08812
2021-06-27 23:51:13 +05:30
title: Alterar o tamanho de imagens
2021-06-15 16:21:20 +02:00
challengeType: 0
forumTopicId: 18282
dashedName: size-your-images
---
# --description--
2021-06-27 23:51:13 +05:30
O CSS tem uma propriedade chamada `width` que controla a largura de um elemento. Assim como com as fontes, usaremos `px` (pixels) para especificar a largura da imagem.
2021-06-15 16:21:20 +02:00
2021-06-27 23:51:13 +05:30
Por exemplo, se quiséssemos criar uma classe CSS chamada `larger-image` que desse aos elementos HTML uma largura de 500 pixels, escreveríamos:
2021-06-15 16:21:20 +02:00
```html
< style >
.larger-image {
width: 500px;
}
< / style >
```
# --instructions--
2021-06-27 23:51:13 +05:30
Crie uma classe chamada `smaller-image` e use-a para redimensionar a imagem para que tenha apenas 100 pixels de largura.
2021-06-15 16:21:20 +02:00
# --hints--
2021-06-27 23:51:13 +05:30
O elemento `img` deve ter a classe `smaller-image` .
2021-06-15 16:21:20 +02:00
```js
assert(
2021-09-22 08:34:59 -07:00
$("img[src='https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg']").attr('class')
2021-06-15 16:21:20 +02:00
.trim().split(/\s+/g).includes('smaller-image')
);
```
2021-06-27 23:51:13 +05:30
A imagem deve ter 100 pixels de largura.
2021-06-15 16:21:20 +02:00
```js
assert(
$('img').width() < 200 & &
code.match(/\.smaller-image\s*{\s*width\s*:\s*100px\s*(;\s*}|})/i)
);
```
# --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;
}
< / style >
< h2 class = "red-text" > CatPhotoApp< / h2 >
< main >
< p class = "red-text" > Click here to view more < a href = "#" > cat photos< / a > .< / p >
2021-09-22 08:34:59 -07:00
< a href = "#" > < img 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 16:21:20 +02:00
< div >
< 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 >
< / div >
< form action = "https://freecatphotoapp.com/submit-cat-photo" >
< label > < input type = "radio" name = "indoor-outdoor" checked > Indoor< / label >
< label > < input type = "radio" name = "indoor-outdoor" > Outdoor< / label > < br >
< label > < input type = "checkbox" name = "personality" checked > Loving< / label >
< label > < input type = "checkbox" name = "personality" > Lazy< / label >
< label > < input type = "checkbox" name = "personality" > Energetic< / label > < br >
< input type = "text" placeholder = "cat photo URL" required >
< button type = "submit" > Submit< / button >
< / form >
< / main >
```
# --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;
}
.smaller-image {
width: 100px;
}
< / style >
< h2 class = "red-text" > CatPhotoApp< / h2 >
< main >
< p class = "red-text" > Click here to view more < a href = "#" > cat photos< / a > .< / p >
2021-06-27 23:51:13 +05:30
2021-09-22 08:34:59 -07:00
< a href = "#" > < img class = "smaller-image" src = "https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt = "A cute orange cat lying on its back." > < / a >
2021-06-27 23:51:13 +05:30
2021-06-15 16:21:20 +02:00
< div >
< 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 >
< / div >
2021-06-27 23:51:13 +05:30
2021-06-15 16:21:20 +02:00
< form action = "https://freecatphotoapp.com/submit-cat-photo" >
< label > < input type = "radio" name = "indoor-outdoor" checked > Indoor< / label >
< label > < input type = "radio" name = "indoor-outdoor" > Outdoor< / label > < br >
< label > < input type = "checkbox" name = "personality" checked > Loving< / label >
< label > < input type = "checkbox" name = "personality" > Lazy< / label >
< label > < input type = "checkbox" name = "personality" > Energetic< / label > < br >
< input type = "text" placeholder = "cat photo URL" required >
< button type = "submit" > Submit< / button >
< / form >
< / main >
```