Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
根据用户屏幕的大小,我使用了三个不同的 css 文件,这样它在移动设备等上看起来不错。前任:
<link rel="stylesheet" media="screen and (max-width: 568px)" href="css/small.css" />
目前我正在使用一些处理页面宽度的jquery,为了让事情更简单,我很想以与css相同的方式加载外部jquery脚本。这是一种可能吗?
使用JavaScript您可以确定的大小screen
JavaScript
screen
screen.height; screen.width;
例如,您可以使用
if(window.screen.width <= 580) { //... }
使用getScript(也可以不使用jQuery),您可以加载脚本
jQuery
$.getScript( "yourscript.js");
但是,我认为,您想要css media query确定设备,无论它是否是手持设备,如果是,那么您可以尝试这个插件。
css media query