CSS子选择器(>)不适用于IE [英] CSS child selector (>) doesn't work with IE

查看:143
本文介绍了CSS子选择器(>)不适用于IE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下CSS在firefox下运行良好,但在IE浏览器下不工作,为什么?

此外,我如何才能使CSS元素直接在父元素下受影响?



CSS:

  .box {font:24px;} 
.Box> div {font:18px}
.box> div> div {font:12px;}

HTML:

 < div class =box> 
level1
< div>
level2
< div> level3< / div>
< div> level3< / div>
< / div>
< div>
level2
< div> level3< / div>
< div> level3< / div>
< / div>
< / div> Internet Explorer支持子选择器(<$ c $ ) c>>
),但仅在标准模式下。请确保您使用的是触发标准模式的Doctype



如果你的目标是IE6,那么你运气不好。你需要依赖于JS或使用后代选择器。

  a> b {foo} 

成为

  ab {foo} 
a * b {reverse-of-foo }


The following CSS works well under firefox but doesn't work under IE browser, Why?
Also, how can I make only the elements, directly under the parent element, be affected by CSS?

CSS:

.box{font:24px;}
.box>div{font:18px}
.box>div>div{font:12px;}

HTML:

<div class="box">
   level1
   <div>
      level2
      <div> level3</div>
      <div> level3</div>
   </div>
   <div>
      level2
      <div> level3</div>
      <div> level3</div>
   </div>
</div>

解决方案

Internet Explorer supports the child selector (>) since version 7, but only in Standards mode. Make sure you are using a Doctype that triggers standards mode.

If you are targeting IE6 then you are out of luck. You need to either depend on JS or use descendant selectors.

a>b { foo }

becomes

a b { foo }
a * b { reverse-of-foo }

这篇关于CSS子选择器(&gt;)不适用于IE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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