使用CSS取决于if语句 [英] Use CSS depend on if statment

查看:109
本文介绍了使用CSS取决于if语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好所有

i在我的网络应用程序中使用ASP.Net,C#。



如何使用css文件取决于如果使用javascript或css的语句?

场景是:如果访客使用IE浏览器,我希望网页使用一个CSS文件,如果访客使用chrome,我希望网页使用其他css文件。



还有另一种情况是:在同一个css文件中写入IE和Chrome浏览器的CSS代码,如果访客使用IE,我希望网页使用以下CSS代码来自css文件:



hello all
i am using ASP.Net, C# in my web application.

how i can use the css file depend on if statment using javascript or css?
The scenario is: if the guest use IE browser i want the web page use one CSS file, and if the guest use chrome i want the web page use the other css file.

also there is another scenario which is: write the both CSS code of IE and Chrome browser in the same css file, and if the guest use IE i want the webpage use the following CSS code from the css file:

.tp_serv2
{
    margin: 30px  15px   0px 5px;
    direction:ltr;
    font-size:14px;
    position:relative;
    top: -1px;
    left: 815px; /* here is the deferent */
    color: #ffffff;
    font-size: 11px;
    font-style: normal;
    font-variant: normal;
    font-weight: bold;
    line-height: 14px;
    font-family: "Trebuchet MS", verdana;
}





如果客人使用Chrome我希望网页使用css文件中的以下CSS代码:





and if the guest use Chrome i want the webpage use the following CSS code from the css file:

.tp_serv2
{
    margin: 30px  15px   0px 5px;
    direction:ltr;
    font-size:14px;
    position:relative;
    top: -1px;
    left: 825px; /* here is the deferent */
    color: #ffffff;
    font-size: 11px;
    font-style: normal;
    font-variant: normal;
    font-weight: bold;
    line-height: 14px;
    font-family: "Trebuchet MS", verdana;
}







我怎么能做第一个场景或第二个场景呢?



谢谢




how i can do the first scenario or second scenario please?

Thank you

推荐答案

因为您可以使用ASP.NET页面,并且每个页面都是在服务器端生成的,它从HTTP请求接收信息,这不是问题。请参阅:

http://msdn.microsoft.com /en-us/library/system.web.httpbrowsercapabilities.aspx [ ^ ]。



对于根据浏览器引用不同CSS的代码示例,请参阅,例如: http://stackoverflow.com/questions / 8698352 / select-different-css-files-based-on-ie-version-in-asp-net [ ^ ]。



-SA
As you can use ASP.NET pages, and each page is generated on the server side which receives information from HTTP request, this is not a problem. Please see:
http://msdn.microsoft.com/en-us/library/system.web.httpbrowsercapabilities.aspx[^].

For the code sample referencing different CSS depending on the browser, please see, for example: http://stackoverflow.com/questions/8698352/select-different-css-files-based-on-ie-version-in-asp-net[^].

—SA


首先将Ur css分为两类



< style>



.tp_serv2

{

First make Ur css into two classes

<style>

.tp_serv2
{
margin: 30px  15px   0px 5px;
    direction:ltr;
    font-size:14px;
    position:relative;
    top: -1px;
    left: 815px; /* here is the deferent */
    color: #ffffff;
    font-size: 11px;
    font-style: normal;
    font-variant: normal;
    font-weight: bold;
    line-height: 14px;
    font-family: "Trebuchet MS", verdana;
}

.tp_serv3
{
margin: 30px  15px   0px 5px;
    direction:ltr;
    font-size:14px;
    position:relative;
    top: -1px;
    left: 825px; /* here is the deferent */
    color: #ffffff;
    font-size: 11px;
    font-style: normal;
    font-variant: normal;
    font-weight: bold;
    line-height: 14px;
    font-family: "Trebuchet MS", verdana;
}


<style>


<body>


<div id="tblid" style="width:40px ; height:40px"></div>

 
</body>


<script>


(文档)。 ready()
{


if
(document).ready() { if (


这篇关于使用CSS取决于if语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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