Tell me the option how to make responsive images?
What you want:
- Under each breakpoint the image is loaded
- Retina display image counted
- Images are scaled
Tell me the option how to make responsive images?
What you want:
To create the most responsive images suitable design
<picture> <source media="(media-query-1)" sizes="(media-query-1.1) x, y" srcset="images/ordinary.jpg"> <source media="(media-query-2)" sizes="(media-query-2.1) z, w" srcset="images/ordinary-2.jpg"> <img src="images/ordinary.jpg"> </picture> <picture> <source media="(max-width: 400px)" srcset="images/ordinary.jpg"> <source media="(min-width: 401px)" srcset="images/ordinary2.jpg"> <img src="images/ordinary2.jpg"> </picture> srcset attribute, write 1x , 2x and, if necessary, 3x . x allows you to refer to device-pixel-ratio . <picture> <source media="(max-width: 400px)" srcset="images/ordinary.jpg 1x, images/ordinary-retina.jpg 2x, images/ordinary-hd.jpg 3x"> <source media="(min-width: 401px)" srcset="images/ordinary2.jpg 1x, images/ordinary2-retina.jpg 2x, images/ordinary2-hd.jpg 3x"> <img src="images/ordinary2.jpg"> </picture> sizes attribute will come to the rescue. We will be implementing the following scenario: 1) for screens less than 800 pixels there will be an image of ordinary.jpg , 1.1) for screens 400 and fewer pixels the image will be 100vw wide, in other cases it will occupy 70vw ; 2) for screens greater than 800 pixels. 2.2. for pixels for screens greater than 1400 pixels, it will have a width of 40vw , otherwise 50vw . <picture> <source media="(max-width: 800px)" sizes="(max-width: 400px) 100vw, 50vw" srcset="images/ordinary.jpg 1x, images/ordinary-retina.jpg 2x, images/ordinary-hd.jpg 3x"> <source media="(min-width: 801px)" sizes="(min-width: 1400px) 40vw, 50vw" srcset="images/ordinary2.jpg 1x, images/ordinary2-retina.jpg 2x, images/ordinary2-hd.jpg 3x"> <img src="images/ordinary2.jpg"> </picture> height width the <img> - so that the browser initially knew what size to render it, even before the picture is loaded. We noticed, probably, that on some sites it happens that the text constantly jumps as the pictures are loaded - this is the case when these attributes are not filled. - Sasha Omelchenkosrcset one address in <source> for srcset : srcset="images/ordinary.jpg" - Sasha OmelchenkoYou can use the srcset attribute (HTML5)
The attribute can be used instead of src and allows you to specify different URL images. The attribute value is one or more comma-separated strings. Each line includes:
optionally whitespace followed by one of:
- the value of the viewport width (it must be a positive integer followed by the symbol “ w ”). The width of the descriptor is divided by the size of the pixel density.
- the pixel density value (a positive number followed by the “ x ” character) is, by default, 1x .
You can through media request + :after + background-image .
Source: https://ru.stackoverflow.com/questions/646607/
All Articles