jquery实现不同大小浏览器使用不同的css样式表的方法
2018-10-12 14:01
471 查看
该方法支持IE浏览器和其他浏览器。
1、首先定义两个link,当然你也可以是一个,第二个是要更改的css
<link rel="stylesheet" type="text/css" href="main.css" />
<link id="size-stylesheet" rel="stylesheet" type="text/css" href="narrow.css" />
2、下面的JavaScript代码将根据不同的浏览器大小,更改css
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());
});
});
以上代码经过测试可用!!
您可能感兴趣的文章:
相关文章推荐
- jquery实现不同大小浏览器使用不同的css样式表的方法
- jquery实现根据浏览器窗口大小自动缩放图片的方法
- jquery实现根据浏览器窗口大小自动缩放图片的方法
- 在 ASP.NET 中实现不同角色的用户使用不同登录界面的方法
- 使用jquery+json实现ajax的方法
- 使用Jquery中getJSON方法实现跨域
- 在 ASP.NET 中实现不同角色的用户使用不同登录界面的方法
- 在 ASP.NET 中实现不同角色的用户使用不同登录界面的方法
- 声明和实现使用不同类,可调用的方法不一样
- 一起谈.NET技术,在 ASP.NET 中实现不同角色的用户使用不同登录界面的方法
- 超棒的跨浏览器纯CSS动画实现 Animate.css使用方法
- 使用RewritePath方法实现【不同路径+任意URL后缀重写到指定页面且URL地址不变】(附源码)_AX
- Linux与Windows中map类erase方法实现的不同决定使用的不同
- JQUERY1.6 使用方法四 检测浏览器
- 在 ASP.NET 中实现不同角色的用户使用不同登录界面的方法
- 在 ASP.NET 中实现不同角色的用户使用不同登录界面的方法
- 使用Jquery中getJSON和getScript方法实现跨域
- jquery 不同浏览器判断颜色值的方法
- 使用Jquery中getJSON和getScript方法实现跨域(转载)