Jquery: how to use different css style sheets for browsers of different sizes

Source: Internet
Author: User
This article mainly introduces jquery's method of using different css style sheets for browsers of different sizes. If you need jquery, you can refer to this method to support IE and other browsers.

1. Define two links first. Of course, you can also be one, and the second is the css to be changed.

The Code is as follows:




2. The following JavaScript code will change css based on different browser sizes.

The Code is as follows:

Function adjustStyle (width ){
Width = parseInt (width );
If (width <701 ){
$ ("# Css"). attr ("href", "css/narrow.css? 1.1.9 ");
} Else if (width> = 701) & (width <900 )){
$ ("# Css"). attr ("href", "css/medium.css? 1.1.9 ");
} Else {
// $ ("# Css"). attr ("href "," ");
Document. write ("css/style.css? 1.1.9 ")
}
}
$ (Function (){
AdjustStyle ($ (this). width ());
$ (Window). resize (function (){
AdjustStyle ($ (this). width ());
});
});


The above code has been 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.