A
A
Arsen Abakarov2016-09-22 14:44:01
css
Arsen Abakarov, 2016-09-22 14:44:01

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

4 answer(s)
V
Vlad, 2016-09-23
@ArsenAbakarov

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">

I
Ilya, 2016-09-22
@Rimush

Look towards Ajax

G
Gleb Gryadk.in, 2016-09-22
@Gryadk_in

maybe:
html5 < picture >
or or < img srcset="" >
?

A
Arsen Abakarov, 2016-09-22
@ArsenAbakarov

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 question

Ask a Question

731 491 924 answers to any question