Different css file code instances and browser window css instances based on different browser window sizes

Source: Internet
Author: User

Different css file code instances and browser window css instances based on different browser window sizes

Different css file code instances vary depending on the browser window size:
In practical applications, different styles may need to be called according to the current browser window. The following is a piece of code that can implement this function.
The Code is 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 {document. write ("css/style.css") }}$ (function () {adjustStyle ($ (this ). width (); $ (window ). resize (function () {adjustStyle ($ (this ). width ());});});

 

The above Code meets our requirements. The code is very simple and will not be described here. For more information, see.
Related reading:
1. For parseInt () functions, see section 1 about parameters of the parseInt () function in js.
2. For more information about the attr () function, see the attr () method section of jQuery.
3. For details about the resize event, see the resize event section of jQuery.

The original address is: http://www.softwhy.com/forum.php? Mod = viewthread & tid = 13049.

For more information, see: http://www.softwhy.com/jquery/

 

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.