Download another browser based css file

How to download various css based on browser type. I want to download various css for IE and Firefox in asp.net. I use IE8 and higher and forefox 3 and higher. please help me.

+6
source share
5 answers

Request.Browser will provide you with complete information about the browser, where you can check the version, browser name, browser type, etc.

if(Request.Browser.Browser == "IE") { HtmlLink css = new HtmlLink(); css.Href = ResolveClientUrl("~/style/StyleSheet.css"); css.Attributes["rel"] = "stylesheet"; css.Attributes["type"] = "text/css"; css.Attributes["media"] = "all"; Page.Header.Controls.Add(css); } 
+6
source

You can use the following conditional css statement to download the css file for IE after the main css file for Firefox and other browsers. This allows you to reuse a lot of the same css code and only overwrite those properties that IE does not get correctly:

 <!--[if lte IE 6]> <link rel="stylesheet" type="text/css" href="styles/browser.css" /> <![endif]--> 

The conditional expression above applies to versions of IE that are less than or equal to IE6, but you can install it as you wish.

You can learn more about CSS conditional statements here: http://www.quirksmode.org/css/condcom.html

+4
source

Your core CSS should be one that is supported by most browsers (including Firefox). You can then use HTML conditional expressions to load specific IE styles.

  <!--[if gt IE 7]> According to the conditional comment this is Internet Explorer greater than IE8<br /> <link rel="stylesheet" type="text/css" href="IEgreatethan7.css"> <![endif]--> 

or if you want to be specific

  <!--[if IE 8]> According to the conditional comment this is Internet Explorer equal to IE8<br /> <link rel="stylesheet" type="text/css" href="IE8.css"> <![endif]--> 
+2
source

You can use this.

 <!--[if IE 7]> <link href="style-ie.css" rel="stylesheet" type="text/css" /> <![endif]--> 

Thanks.

+2
source
0
source

Source: https://habr.com/ru/post/892880/


All Articles