简体   繁体   English

无法加载“移动” CSS?

[英]Can't load a 'Mobile' CSS?

i currently have this code working on my website: 我目前在我的网站上有此代码:

<script>
if (window.top!=window.self) { 
    loadCSSFile("http://www.website.com/css/iframe.css");
} else { 
    loadCSSFile("http://www.website.com/css/style.css");
}
</script>

I am looking to fix this as i want to load three files but only if required? 我想修复此问题,因为我想加载三个文件,但仅在需要时才这样做? hoping you use php or add to the script above, currently this loads normal Css and CSS for Iframe (Facebook Apps) and now i want to style the mobile css, but with one file mobile.css i need to add a file to the above or a php code that handles this? 希望您使用php或添加到上面的脚本中,当前这会为iframe(Facebook Apps)加载普通的CSS和CSS,现在我想为移动CSS设置样式,但是要使用一个文件mobile.css,我需要在上面添加文件或处理此问题的php代码?

Cheers! 干杯!

<link rel="stylesheet" media="(max-width: 800px)" href="mobile.css" />

请不要为此使用JS。

If you to load a CSS to style for mobile devices you can use the following code. 如果要加载CSS以为移动设备设置样式,则可以使用以下代码。 This will detect that the device is a mobile by looking at the screen size and if it matches then it will load the css. 这将通过查看屏幕尺寸来检测设备是否为移动设备,如果匹配,则将加载CSS。

<link media="handheld, only screen and (max-width: 480px), only screen and (max-device-width: 480px)" href="mobile.css" type="text/css" rel="stylesheet" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM