nth-child does not work in Safari

冷暖自知 提交于 2020-01-04 02:06:27

问题


I'm trying following CSS, it works in Firefox and Chrome but does not work in the Safari (5.1). I have checked Safari supports nth-child. What I'm doing wrong?

CSS:

option:nth-child(2){
  display: none;
}

HTML:

<select>
   <option value="1">One</option>
   <option value="2">Two</option>
   <option value="3">Three</option>
</select>

Demo: http://jsfiddle.net/Kv9tj/


回答1:


You can always use: nth-of-type(2) .

Browser support for :nth-of-type is fairly decent... Firefox 3.5+, Opera 9.5+, Chrome 2+, Safari 3.1+, IE 9+.

I hope this will help you!!!




回答2:


I think your problem is not nth-child, but display: none on option.
For example, see this answer: https://stackoverflow.com/a/15025961/39068 (to a similar question).

It says that you can not set display: none on option in Safari or IE.



来源:https://stackoverflow.com/questions/17312140/nth-child-does-not-work-in-safari

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!