Answer the question
In order to leave comments, you need to log in
How to make responsive photos in background-image?
Hey!
I am 2 years behind the layout trends of the year. I am redesigning my project for an adaptive grid, at the same time studying the topic.
There are many photos on the page (30-40 pieces). Now I load their large versions (300-500 Kb) for any screen resolution. As a result, the page weighs under 15 megabytes. That's not the point. Started digging towards adaptive images. I came up with this way:
<?while(...вывожу картинки из БД...){?>
<div id="img_XXX" style="background-image:url(XXX_small.jpg)"></div>
<style>
@media (min-width: 960px) {
#img_XXX {background-image: url(XXX_big.jpg) !important;}
}
</style>
<?}?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question