English 中文(简体)
如何避免将CSS的档案装上单垫大小装置(机动和全尺寸之间)?
原标题:How to avoid loading CSS file for ipad sized devices ( between mobile and full-sized)?
  • 时间:2011-11-22 21:03:46
  •  标签:
  • html
  • css

我的申请对屏幕有好评,但有一个硬性框架,难以在流动和类似情况下使用。 因此,我已经为安装这些装置提供了专门的CSS档案。 ok,我使用的是main.cs,其中界定了一般检查(所有媒体)和handheld.cs文档,对此类装置做了更正:

<link rel="stylesheet" media="all" type="text/css" href="main.css" />
<link rel="stylesheet" media="handheld,tv" type="text/css" href="handheld.css" />

问题在于,像iPad这样的一些装置对一般屏幕版本有很大的检查,不需要像一些移动设备那样降低等级。 因此,我把一个连接点放在我的肩上,把这个部队像在桌面屏幕上显示的那样。 问题在于我不知道如何强迫不装载handheld.cs。 可能的话? 但是,如何?

最佳回答

I think what you re looking for is media queries. This won t solve your question, but it is how you should go about solving the bigger problem (layout responding to different screen sizes) in the future.
Example: http://www.barackobama.com/ (resize the width of page to see what it does)
Learn how:
http://coding.smashingmagazine.com/2010/07/19/how-to-use-css3-media-queries-to-create-a-mobile-version-of-your-website/
http://www.vanseodesign.com/css/media-queries/
http://www.adobe.com/devnet/dreamweaver/articles/introducing-media-queries.html
http://designmodo.com/media-queries/

To solve your specific problem, read below:
working example of website with css stylesheet switching:
http://jsfiddle.net/y6FWK/2/

这对我来说是一个新事物。 由于<代码><link> 仅是另一个主要内容,你可以仅提及(最容易给予该编码)并简单改动其<代码>href价值...... 我感到惊讶。

<link rel="stylesheet" type="text/css" href="" id="cssSwitch" />

然后,一些县会改变......或你喜欢的东西。

<input type="button" id="enableMobile" value="mobile css" />
<input type="button" id="enableMain" value="main.css" />

之后,根据你的法典:

$("#enableMobile").on("click", function(){
    $("#cssSwitch").attr("href", "handheld.css");
});

$("#enableMain").on("click", function(){
    $("#cssSwitch").attr("href", "main.css");
});

令我惊讶的是,网站

<> 试验和工作<>

  • IE (8)
  • Chrome (15)
  • FireFox
  • Android Samsung Galaxy S (default browser)
问题回答

如何使用媒体?

比如,你可以将其用于目标器具,其宽度低于800px。 它将针对大多数现代移动浏览器开展工作。

为使单单单单适用于移动版本,我个人宁愿创造名称空间,以补充/删除地毯。

例如:

  1. You write all rules in the handheld.css as ".handheld .classname".
  2. For mobile version you add class ".handheld" on body.

创建非js版本的网页也是有益的: 您在身体上课“......nojs”,在用Javascript(如果能做到这一点)去除。

页: 1 用户-代理人 头盔服务器部分,然后确定您是否应当服务手持。 视您的服务器方语言/镜头,有许多图书馆能够帮助您确定用户的装置/装置。 当然,铭记<代码> 用户-代理人可以签名。 但对于大多数来访者来说,这应当足够好。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签