Exclude single browser from using a CSS class

2019-05-07 12:55发布

I'd like to exclude Internet Explorer from using a specific CSS class. Is this possible?

Details:

I have a css class that looks like -

input[type="radio"]:checked, input[type="radio"]:hover
{
   box-shadow: 0px 0px 10px #90BBD4;
}

Since Firefox's latest browser update removed the -moz-box-shadow property and I believe it now uses the default box-shadow instead, ... my Firefox is still working great, but Internet explorer now recognizes it and messes up the look.

How might I go about excluding IE from using this class or work around it somehow?

3条回答
Rolldiameter
2楼-- · 2019-05-07 13:32

When people feel the need to make their website look different in different browsers (which is the complete opposite of what the Internet should be like...) they use this:

<!--[if IE]><html class="ie"><![endif]-->
<!--[if !IE]>--><html><!--<![endif]-->

Then in your CSS you can put html.ie to make IE-specific rules.

查看更多
Juvenile、少年°
3楼-- · 2019-05-07 13:36

This will set a class of the IE version the client browser is using.

<!--[if lt IE 7 ]> <html class="ie6" lang="en" xml:lang="en"> <![endif]-->
<!--[if IE 7 ]>    <html class="ie7" lang="en" xml:lang="en"> <![endif]-->
<!--[if IE 8 ]>    <html class="ie8" lang="en" xml:lang="en"> <![endif]-->
<!--[if IE 9 ]>    <html class="ie9" lang="en" xml:lang="en"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html class="" lang="en"> <!--<![endif]-->

Then using CSS you can target it to a specfic browser by using something like:

.ie7 #wrapper
  {
     display:none;
  }
查看更多
我欲成王,谁敢阻挡
4楼-- · 2019-05-07 13:52

You can use IE conditional comments and set css rules in the css you include inside the comment.

For example:

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

or:

<!--[if IE]><style>*ie style rules here*</style><![endif]-->
查看更多
登录 后发表回答