开发者

css conditions for browser

can you have a setting for say margin-right for different browsers in the css page like i want margin开发者_JAVA技巧-right for google chrome or mozila browsers and another margin right for ie e.g

if ie margin-right: -1px; if mozilla margin-right: -2px;

like switches in css


There are not actual switches (in the strictest sense) for CSS. For IE, in HTML, you can use conditional comments, like the following:

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

Conditional comments allow you to override default CSS with IE-only (or specific version(s) of IE-only) CSS to fix some quirks with CSS.

For actual coding, you could sniff out the user agent of a browser using JavaScript or PHP, and dynamically generating CSS based on the user agent.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜