jquery implements different CSS style sheets for different sizes of browsers

Source: Internet
Author: User

  This article mainly introduces jquery to achieve different size browser using different CSS style sheet method, the need for friends can refer to the following

This method supports IE browsers and other browsers.   1, first define two link, of course you can also be a, the second is to change the CSS   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 sizes, Change the CSS code as follows: function Adjuststyle (width) {      width = parseint (width);      if (Width < 7 {          $ ("#css"). attr ("href", "css/narrow.css");     } else if (width &G t;= 701) && (Width < 900)) {          $ ("#css"). attr ("href", "css/medium.css");     } else {         //$ ("#css"). attr ("href", "<?php bloginfo" (' Stylesheet_url '); gt; ");          document.write ("Css/style.css")    } }  $ (function () {  &nbs P   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.