Home  >  Article  >  Web Front-end  >  js code to determine screen resolution_javascript skills

js code to determine screen resolution_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:28:431353browse

Generally we can judge the resolution through the following code

Copy code The code is as follows:


js determines browser resolution

Copy code The code is as follows:

<script><br>function ScreenWidth(){ <br>                                                                                                                                                                                ("800*600" ; ;<br>         }<br>}<br></script>




Note: This js code can be modified and changed to screen.width>=1024 and screen.width=800 in two cases

So I chose to use the following code:

Copy code

The code is as follows:


Use JS to determine different resolutions and call different CSS style files

I recently looked at a website and found that different monitor resolutions call style files differently. Today I wrote an example to study it,

Copy code


The code is as follows:

Untitled Document









Contents in c1.css



Copy code

The code is as follows:

Content inside c2.css

*{ margin:0; padding:0;}

div{ width:1200px; height:400px; margin:0 auto; background:red; color:#fff;}


Statement:
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