如何可靠是“>”? [英] How reliable is ">"?

查看:140
本文介绍了如何可靠是“>”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

> 字符可以与CSS一起使用,以选择具有某个父级的元素。
我在这里看到的好处是,我可以应用样式只有某一级别的列表为例。像菜单 - 第一级是水平的,有不同的规则比第二级+。所以我不需要担心重置属性为lvl 2 +

The > character can be used with CSS to select an element that has a certain parent. The benefit I see here is that I can apply styles only to a certain level of a list for example. Like menus - first level is orizontal and has different rules than 2nd level+. so i don't need to worry about resetting properties for lvl 2+

无论如何,我可以依赖>

Anyway, can I depend on >? Is it supported by all browsers and without buggy behaviors?

推荐答案

子选择器> 完全支持IE7和更高版本,而不是在IE6和更早。当然,现在使用的所有其他主要浏览器的所有版本也支持它。

The child selector > is fully supported by IE7 and later, and not at all in IE6 and earlier. Of course, all versions of all other major browsers in use today support it fully as well.

所有CSS2.1选择器都是由IE8和更高版本支持,因此您今天可以使用,除非您正在编写需要满足IE6的旧代码,在这种情况下避免使用

All CSS2.1 selectors are well-supported by IE8 and later so you can use them today, unless you're writing legacy code that needs to cater to IE6, in which case avoid them where possible.

SitePoint参考确实提到了一个与影响IE7的注释相关的模糊解析错误,但是如果有注释,它只会中断选择器。你通常不会在选择器的中间放置注释,除非你这样做是一个黑客,所以你不需要担心这个bug。

The SitePoint Reference does mention an obscure parsing bug related to comments that affects IE7, but it only breaks the selector if a comment is there. You don't usually put comments in the middle of selectors unless you're doing so as a hack, so you don't need to worry about this bug.

相关: CSS子选择器是否为W3C标准?(当然,它们是!)

Related: Are CSS child selectors a W3C standard? (Of course they are!)

这篇关于如何可靠是“>”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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