What CSS should I use to get a border around an op

2020-02-15 07:34发布

问题:

Right now I am using the following CSS:

option
{
    border-width: 1px;
    border-style: solid;
}

Which works fine in Firefox but not in IE. I'm not sure if it makes a difference but the option tags are generated by an ASP.NET ListBox control.

回答1:

Unfortunately, the styling of option elements is supported to different degrees by different browsers. Firefox is the only browser which allows you to add a border around options – IE and Chrome won't show a border.

Here's an overview of what styles different browsers support. The only styling you can reliably apply is background and foreground color.



回答2:

Maybe this way it would work?!

border: 1px solid black;

Never had problems with this, could be something else , parent elements and so on...



回答3:

Add a border-color to your declaration.

option
{
    border-width: 1px;
    border-style: solid;
    border-color: #000;
}