K
K
Kerim Berdimyradov2016-05-03 18:16:38
css
Kerim Berdimyradov, 2016-05-03 18:16:38

How not to load an image on mobile devices?

I know that you can use media spaces to hide pictures

@media screen and (max-width: 768px) {
          img {
                 display: none;
         }
}

I also know that using the same media queries, you can track the screen resolution and load the necessary pictures (for example, for retina)
#logo {
  background-image: url('/images/my_image.png');
}

@media all and (-webkit-min-device-pixel-ratio: 1.5) {
  #logo {
    background-image: url('/images/[email protected]');
    background-size: 200px 100px;
  }
}

So here it is! If there is any way (preferably through the same media queries), so that you can track the width of the screen and, depending on the width, load or not load pictures?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
profesor08, 2016-05-03
@berdimuradov

Do not use img , but instead use div and set the background image in CSS via media or not.

D
display: block, 2016-05-03
@qork

Use srcset.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question