如何使用Java Script在asp.net中基于屏幕分辨率设置样式表 [英] how to set style sheet on the basis of screen resolution in asp.net using Java Script

查看:89
本文介绍了如何使用Java Script在asp.net中基于屏幕分辨率设置样式表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有2张样式表:

Hi All,

I have 2 style sheets as :

<link rel='stylesheet' type='text/css' href='style1.css' />





and

<link rel='stylesheet' type='text/css' href='style.css' />

现在在screen.width的基础上我必须为页面设置样式表例如

如果screen.width大于1280然后想要设置第一个样式表,否则second.how要做这个页面加载。



请帮忙。





谢谢< br $> b $ b

mohd w asif

Now the on basis of screen.width i have to set the style sheets for the page e.g.
If screen.width is greater then 1280 then want to set first style sheet else second.how to do this on page load.

Please help.


thanks

mohd wasif

推荐答案

你不需要javascript就可以设置媒体查询


You don't need javascript you can set a media query


我不建议为此使用两种不同的样式表。现在,移动设备,标签和笔记本电脑拥有多种类型的屏幕尺寸。如果您决定处理那么多分辨率,则必须编写那么多样式表。处理并增加页面请求是不方便的。



这就是专业人士建议在单一样式表中编写媒体查询的原因。喜欢这个





@media only screen and(min-width:320px)and(max-width:480px){

/ *手机款式* /

}





@media only screen and(最小宽度:481px)和(最大宽度:800px){

/ *标签样式* /

}





@media only screen and(min-width:801px)and(max-width:1024px){

/ * Desktops Styles * /

}



查看此链接

http://waybloggy.blogspot.com/2014/09/components-required-for-responsive-web.html [ ^ ]
I would not recommend to use two different style sheets for this. Now a days mobiles, tabs and laptops are having many types of screen sizes. If you decide to handle that many resolutions you have to write that many style sheets. It is inconvenient to handle and also increase your page requests.

That's why professionals recommend to write media queries inside single style sheet. Like this


@media only screen and (min-width : 320px) and (max-width : 480px) {
/* mobile Styles */
}


@media only screen and (min-width : 481px) and (max-width : 800px) {
/*Tab Styles */
}


@media only screen and (min-width : 801px) and (max-width : 1024px) {
/*Desktops Styles */
}

Check it out this link
http://waybloggy.blogspot.com/2014/09/components-required-for-responsive-web.html[^]


这篇关于如何使用Java Script在asp.net中基于屏幕分辨率设置样式表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆