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/