3

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/

user1251698
  • 2,103
  • 12
  • 35
  • 51
  • possible duplicate of [How to style a – uber5001 Jun 26 '13 at 05:28

2 Answers2

7

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 was having similar issues with displaying :nth-childs as none, and changing it to :nth-of-type cleared it right up on Safari mobile. – Justin Medas Oct 21 '14 at 14:08
1

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.

Community
  • 1
  • 1
Andrey Shchekin
  • 21,101
  • 19
  • 94
  • 162