Answers for "how to fill image in div"

3

css image fit in div with aspect ratio

img {
    width: 100%;
    height: 100%; 
    object-fit: contain;
}
Posted by: Guest on July-02-2020
2

is there an img cover

body {
  margin: 0;
}
img {
  display: block;
  width: 100vw;
  height: 100vh;
  object-fit: cover;
}
Posted by: Guest on February-26-2020
1

image to fill div

.fill {
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden
}
.fill img {
    flex-shrink: 0;
    min-width: 100%;
    min-height: 100%
}
Posted by: Guest on March-21-2021
0

fill image in div

img {
  width: 200px;
  height: 
  300px;
  object-fit: cover;
}
Posted by: Guest on August-23-2021

Browse Popular Code Answers by Language