How can I set the background color of

前端 未结 4 1628
梦如初夏
梦如初夏 2020-12-03 16:49

How do you set the background color of an item in an HTML list?

相关标签:
4条回答
  • 2020-12-03 17:06

    Just like normal background-color: #f0f

    You just need a way to target it, eg: <option id="myPinkOption">blah</option>

    0 讨论(0)
  • 2020-12-03 17:12

    I had this problem too. I found setting the appearance to none helped.

    .class {
        appearance:none;
        -moz-appearance:none;
        -webkit-appearance:none;
    
        background-color: red;
    }
    
    0 讨论(0)
  • 2020-12-03 17:14

    I assume you mean the <select> input element?

    Support for that is pretty new, but FF 3.6, Chrome and IE 8 render this all right:

    <select name="select">
      <option value="1" style="background-color: blue">Test</option>
      <option value="2" style="background-color: green">Test</option>
    </select>

    0 讨论(0)
  • 2020-12-03 17:23

    select.list1 option.option2
    {
        background-color: #007700;
    }
    <select class="list1">
      <option value="1">Option 1</option>
      <option value="2" class="option2">Option 2</option>
    </select>

    0 讨论(0)
提交回复
热议问题