Como fazer - Imagens responsivas
Aprenda a criar uma imagem responsiva com CSS.
As imagens responsivas se ajustarão automaticamente ao tamanho da tela.
Redimensione a janela do navegador para ver o efeito responsivo:
Como criar imagens responsivas
Etapa 1) Adicionar HTML:
Exemplo
<img src="nature.jpg" alt="Nature" class="responsive">
Etapa 2) Adicionar CSS:
Se você quiser que a imagem aumente e diminua a capacidade de resposta, defina a width
propriedade CSS para 100% e height
para automático:
Exemplo
.responsive {
width: 100%;
height: auto;
}
If you want an image to scale down if it has to, but never scale up to be larger than its original size, use max-width: 100%
:
Example
.responsive {
max-width: 100%;
height: auto;
}
If you want to restrict a responsive image to a maximum size, use the max-width
property, with a
pixel value of your choice:
Example
.responsive {
width: 100%;
max-width:
400px;
height: auto;
}
Go to our CSS Images Tutorial to learn more about how to style images.
Go to our CSS RWD Tutorial to learn more about responsive web design.