“CSS Keep Aspect Ratio Image” Réponses codées

Le rapport d'image CSS Keep Image

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

Garder le rapport d'aspect de l'image CSS

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

Comment définir la taille de l'image sans modifier le rapport d'aspect dans CSS

img {
  display: block;
  max-width:230px;
  max-height:95px;
  width: auto;
  height: auto;
}
Zunayed

CSS Keep Aspect Ratio Image

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

Rapport d'aspect HTML Image Keep

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

Réponses similaires à “CSS Keep Aspect Ratio Image”

Questions similaires à “CSS Keep Aspect Ratio Image”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code