Telegram Group & Telegram Channel
Приветствую фронты! Давно уже слышал про такую тему как <picture /> но применить на практике пришлось вот только недавно.

Задача: Отображать разные картинки в зависимости от размера девайса

Можно сделать и через CSS, но минус такого подхода в том что рендерится все-равно 2 картинки, а если элементов в которых нужно сделать такую подмену много(как у меня было) то это влияет на производительность. В итоге вспомнил про picture и применил его:

Выглядит примерно так:

<picture>
<source media="(min-width:650px)" srcset="big_pic.jpg">
<source media="(min-width:465px)" srcset="small_pic.jpg">
<img src="pic.jpg" alt="pic" style="width:auto;">
</picture>


В общем вот вам, экспериментируйте =)



tg-me.com/projavascript/77
Create:
Last Update:

Приветствую фронты! Давно уже слышал про такую тему как <picture /> но применить на практике пришлось вот только недавно.

Задача: Отображать разные картинки в зависимости от размера девайса

Можно сделать и через CSS, но минус такого подхода в том что рендерится все-равно 2 картинки, а если элементов в которых нужно сделать такую подмену много(как у меня было) то это влияет на производительность. В итоге вспомнил про picture и применил его:

Выглядит примерно так:

<picture>
<source media="(min-width:650px)" srcset="big_pic.jpg">
<source media="(min-width:465px)" srcset="small_pic.jpg">
<img src="pic.jpg" alt="pic" style="width:auto;">
</picture>


В общем вот вам, экспериментируйте =)

BY Javascript Pro


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/projavascript/77

View MORE
Open in Telegram


Javascript Pro Telegram | DID YOU KNOW?

Date: |

Start with a fresh view of investing strategy. The combination of risks and fads this quarter looks to be topping. That means the future is ready to move in.Likely, there will not be a wholesale shift. Company actions will aim to benefit from economic growth, inflationary pressures and a return of market-determined interest rates. In turn, all of that should drive the stock market and investment returns higher.

The seemingly negative pandemic effects and resource/product shortages are encouraging and allowing organizations to innovate and change.The news of cash-rich organizations getting ready for the post-Covid growth economy is a sign of more than capital spending plans. Cash provides a cushion for risk-taking and a tool for growth.

Javascript Pro from us


Telegram Javascript Pro
FROM USA