简体   繁体   中英

Is it possible to choose the media for each screen size without media queries?

I must create a page where there is a banner with a video on desktop and an image on tablet/mobile. Is there something like the <picture> HTML tag who can combine images and videos for each specified breakpoint without media queries ? (srcset or source).

I know that I can hide the video on tablet breakpoint and display the image but it's not optimal for performances because the video is still loading on mobile.

Thanks for your help

Media queries for video are deprecated (exited in Chrome 36 or something like that)

You can use JavaScript to get the screen size, and then add the video or image tag based on the response.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM