Home > Web Front-end > JS Tutorial > body text

jQery Centers Web Pages on Displays for Any Resolution_jquery

WBOY
Release: 2016-05-16 16:45:28
Original
1212 people have browsed it

Detect the screen width and set it to the width of the div with the id of frame. Adjust it according to the maximum width of your web page. The maximum width of the small demo is 1440

Copy code The code is as follows:




< meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Untitled Document

<script> <br>function onWidthChange(){ <br>var w=$(window).width( ); <br>x=(w-1440)/2; <br>$("#frame").css("width",w); <br>if(w<1024){ <br>$( "#frame").css("overflow","visible"); <br>$("#webContent").css("margin-left",x); <br>}else if(1024<w< 1440){ <br>$("#frame").css("overflow","hidden"); <br>$("#webContent").css("margin-left",x); <br> } <br>setTimeout(onWidthChange,0); <br>}; <br></script>




//Content


< /body>

Related labels:
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