“Mantenga la relación de aspecto de la imagen CSS” Código de respuesta

CSS Keep Ratio de imagen

img {
  object-fit: cover;
  width: 100px;
  height:100px;
}
monospace

Mantenga la relación de aspecto de la imagen CSS

img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
}
Mobile Star

CSS Mantenga la imagen de relación de aspecto

.image-full {
    background: url(...some image...) no-repeat;
    background-size: cover;
    background-position: center center;
}
Breakable Batfish

Relación de aspecto de mantenimiento de imagen HTML

Don't set height AND width. Use one or the other and the correct aspect ratio will be maintained.
Delightful Duck

Respuestas similares a “Mantenga la relación de aspecto de la imagen CSS”

Preguntas similares a “Mantenga la relación de aspecto de la imagen CSS”

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código