Answer the question
In order to leave comments, you need to log in
Different photo sizes for different product cards in an online store?
The bottom line is this:
Photos are stored in different sizes, one size for grid display, another for display as a list.
They are displayed on the site via the HTML img tag
. In CSS, I registered a media query to rebuild the product card into a list when the browser is narrowed, but I can’t figure out how to replace the image with a smaller one?
I thought about resize in js, but if the user opens the site already in a narrow window?
Answer the question
In order to leave comments, you need to log in
As an option
.show-img__small {
display: block;
}
.show-img__big {
display: none;
}
@media handheld, screen and (min-width: 1024px) {
.show-img__small {
display: none;
}
.show-img__big {
display: block;
}
}
<img src="path/to/image/small" class="show-img__small">
<img src="path/to/image/big" class="show-img__big">
So far I've done everything through js without CSS, hung it on the onload and resize functions, I'm waiting for more elegant solutions
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question