English 中文(简体)
Java 或 j 用于根据屏幕尺寸转换文档[封闭]
原标题:JavaScript or jQuery to convert css files according to screen size [closed]

我可以针对使用该守则的所有浏览器:

<link rel="stylesheet" media="screen and (min-device-width: 1024px)" href="large.css"/> 
<link rel= stylesheet  media= screen and (min-width: 1023px) and (max-width: 1025px)  href= medium.css  />
<link rel= stylesheet  media="screen and (min-width: 419px) and (max-width: 1023px)"  href= small.css  />

但是,媒体的问询设计并不涉及旧版本的IEE,因此我与这一浏览器一样有问题。

问题回答

利用这支 j子pet子在BODY tag上课:

$(document).ready(function(){
  var width = $(window).width();
  var class =  small ;

  if(width > 1024) {
    class =  large ;
  } else if(width > 1023 && width < 1025) {
    class =  medium ;
  }

  $( body ).addClass(class);
});

有了适当的班级(大型/中型/小型),你就能够照样写:

 body.large p {font-size: 25px};
 body.medium p {font-size: 20px};
 body.small p {font-size: 15px};

等等。

有若干个 出现在调压器上,其中包括几个声称支持媒体询问的人。

我确实建议采用 j类替代品,例如ze。

rel=“nofollow”>http://rezitech.github.com/syze/





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签