Home >Web Front-end >JS Tutorial >jQery Centers Web Pages on Displays for Any Resolution_jquery

jQery Centers Web Pages on Displays for Any Resolution_jquery

WBOY
WBOYOriginal
2016-05-16 16:45:281249browse

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>

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