jquery implements methods for different size browsers using different CSS style sheets _jquery

Source: Internet
Author: User

This method supports IE browsers and other browsers.

1, first define two link, of course you can also be one, the second is to change the CSS

Copy Code code as follows:

<link rel= "stylesheet" type= "Text/css" href= "Main.css"/>
<link id= "Size-stylesheet" rel= "stylesheet" type= "Text/css" href= "Narrow.css"/>

2, the following JavaScript code will be based on different browser size, change the CSS
Copy Code code as follows:
function Adjuststyle (width) {
width = parseint (width);
if (Width < 701) {
$ ("#css"). attr ("href", "css/narrow.css");
else if ((width >= 701) && (Width < 900)) {
$ ("#css"). attr ("href", "css/medium.css");
} else {
$ ("#css"). attr ("href", "<?php bloginfo (' Stylesheet_url ');?>");
document.write ("Css/style.css")
}
}
$ (function () {
Adjuststyle ($ (this). width ());
$ (window). Resize (function () {
Adjuststyle ($ (this). width ());
});
});

The above code is tested and available!!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.