2015-08-25 53 views
3


其实我只需要在IE-11和所有的浏览器属性的CSS文件中的其余部分指定此属性只在CSS文件中指定的IE CSS属性

margin-left:-20px; 

.navigator li a span { 
    display: block; 
    float: right; 
    width: 80px; 
    height: 50px; 
    margin-right: -10px; 
    margin-left:-20px; 
    } 

有没有办法做到这一点,因为我尝试了很多解决方案,并没有工作
在此先感谢!

+6

为什么你只需要'保证金left'的IE?如果这是由于IE中的显示问题造成的,那么可能有更好的方式来处理这个问题,而无需使用浏览器嗅探。 –

+2

微软删除浏览器特定的CSS从最新的浏览器,但可以用一个黑客这样做(http://stackoverflow.com/questions/20541306/how-to-write-a-css-hack-for-ie-11)不尽管推荐!你应该尝试解决潜在的问题,因为ie11相对比较现代化,并且应该遵守标准。 –

+1

您的代码是否在IE10上工作或其他人已经检查过。? –

回答

2

我写的很简单,只通过IE 11+

<style type="text/css"> 
 
    _:-ms-fullscreen, :root .msie11 { color: blue; } 
 
</style> 
 

 
// or you can try this 
 

 
<style> 
 
    @media all and (-ms-high-contrast:none) 
 
    {   
 
     *::-ms-backdrop, .foo { color: red } /* IE11 */ 
 
    } 
 
</style>

,当然还有DIV支持...

<div class="msie11"> 
 
    This is an Internet Explorer 11 and greater CSS Hack 
 
<div>

,使文本显示亮蓝与Internet Explorer 11和更大。玩得开心。

更多的参考,你可以看看周围的给定链路

Reference

+0

谢谢,这很有用。 – Yasmin

+0

@Yasmin贵人帮助你,如果你找到答案的帮助充满你可以接受的答案,也可以给予好评它 –

+0

@Yasmin,你应该接受任何如下回答,使这种情况下可以关闭 –

1

这听起来像你的问题可能比浏览器的条件样式一些其他的方式来解决,请首先尝试,但在任何情况下:

对于IE 10和11,您可以使用此:

@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) { 
/* IE10+ CSS styles go here */ 
} 

不过请注意,它可以识别两个IE 10和11

来源:https://philipnewcomer.net/2014/04/target-internet-explorer-10-11-css/

你也可能想看看这个:

http://marxo.me/target-ie-in-css/


对于IE 9,下,您可以使用此:

您创建一个单独的样式表,并那么你可以使用它来将它包含在你的HTML中。

来源:https://css-tricks.com/how-to-create-an-ie-only-stylesheet/

例如,如果你想针对IE 7,你可以这样做。您可以将版本号更改为您的意愿。

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

然后,还可以针对更低或更高的版本比特定版本:

低于IE 8和IE 8:

<!--[if lte IE 8]> 
    <link rel="stylesheet" type="text/css" href="ie8-and-down.css" /> 
<![endif]--> 
比IE 8更高

<!--[if gt IE 8]> 
    <link rel="stylesheet" type="text/css" href="ie6-and-up.css" /> 
<![endif]--> 

请注意,您可以使用lt,lte,gtgte

+0

从您链接到非常文章:“请注意,IE 10和最多不支持有条件的意见在所有” _ _ – CBroe

+0

@CBroe太糟糕了,我才意识到我自己也是如此。所以,这不适用。我也为IE 10和11添加了一个解决方案,尽管它可以识别它们。 – Roope

+0

非常感谢您的帮助,我也会尝试这个解决方案。 – Yasmin