浏览器支持 CSS :first-child 和 :last-child

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7938521/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 02:02:02  来源:igfitidea点击:

Browser support for CSS :first-child and :last-child

cssbrowsercss-selectors

提问by Alex

Does anyone know which browsers/version support them?

有谁知道哪些浏览器/版本支持它们?

Is it safe to use them, or should I resort to PHP / javascript to generate first/last classes?

使用它们是否安全,还是应该使用 PHP/javascript 来生成第一个/最后一个类?

回答by Bojangles

:first-childand :last-child, along with complimentary compatibility chart.

:first-child以及:last-child免费的兼容性图表

:first-childis supported IE9 properly, and IE7 and IE8 sort of (see chart).

:first-child正确支持 IE9,以及 IE7 和 IE8(见图表)。

:last-childis supported by IE9+ only.

:last-child仅 IE9+ 支持。

Both of them are supported well by the good browsers.

好的浏览器都很好地支持它们。

回答by Hristo

"Can I use..."should be your go to resource for these types of questions. Here's are the compatibility tables:

“我可以使用......”应该是您解决这些类型问题的资源。以下是兼容性表:

first-child- http://caniuse.com/#feat=css-sel2

first-child- http://caniuse.com/#feat=css-sel2

last-child- http://caniuse.com/#feat=css-sel3

last-child- http://caniuse.com/#feat=css-sel3

回答by Darin Dimitrov

Here's a nice tableillustrating different browser support.

这是一个很好的表格,说明了不同的浏览器支持。