How to fit an image to fit the screen
2 answers
Is this what you want:
img {
width: 100%;
height: auto;
}
If you want your image to scale differently (or add / override some styles for more users) on different devices, you need to use CSS Query Queries. For example.
img {
display: inline-block;
width: 25%; // Show 4 images in a row normally
height: auto;
}
@media (max-width: 600px) {
img {
width: 100%; // Override width to show only one image in a row on smaller screens
}
}
+8
source to share