How to display different pictures according to different screen resolutions? _html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:50:00
Original
2060 people have browsed it

If the screen width is less than 1400, use picture 1.
If it is larger, use picture 2, and specify the width of the picture to be the width of the screen.


Reply to discussion (solution)

Define window.screen.width and pass it to the background output.

<script> <br> if(window.screen.width<1400){ <br /> document.write("<img src='img1.png' style='width:100%' text-align='center'>"); <br> }else{ <br> document.write("<img src='img2.png' style='width:100%' text-align='center'>"); <br> } <br> </script>

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!