Bold second item of a selectOneMenu

后端 未结 1 1594
醉酒成梦
醉酒成梦 2021-01-21 14:07

I\'ve got a selectOneMenu which has all cities of a state. I\'ve made a sql to bring capital in first place, but i\'d like to bold it to make it more visible to who is using it.

1条回答
  •  情话喂你
    2021-01-21 14:34

    The HTML element as generated by allows for very little fine-grained styling and the CSS support is browser-dependent. You could use the CSS3 :nth-child pseudoselector. E.g.

    
        
    
    

    with

    .cities option:nth-child(2) {
        font-weight: bold;
    }
    

    But this doesn't work in all browsers. Only Firefox eats that, but MSIE and Chrome not. The latter two doesn't do that because they don't allow setting font-weight on the option. But they allows you to change the (background) color by color or background-color:

    .cities option:nth-child(2) {
        background-color: pink;
    }
    

    This works in all CSS3 capable browsers so far (i.e. thus not in MSIE8 or older).

    If you want best cross browser compatibility, you'd need to replace the

    提交评论

提交回复
热议问题