HTML Select DropDown list with multiple colours

前端 未结 4 1319
野趣味
野趣味 2020-12-20 13:40

Is it possible to have different colours for different items in the dropdown list?

For example:

Option 1 = green
Option 2 = blue
etc

相关标签:
4条回答
  • 2020-12-20 14:30
                        <div class="col-lg-3">
                            <label>Job Status:</label>
                            <select type="text" name="fname" class="form-control"  placeholder="Job Status" >
                                    <option value="">Select Status</option>
                                    <option class="btn btn-success"  value="Working">Working</option>
                                    <option class="btn btn-warning"  value="In Proccess">In Proccess</option>
                                    <option class="btn btn-danger" value="Closed">Closed</option>
                            </select>
                        </div>
    
    0 讨论(0)
  • 2020-12-20 14:31

    CSS and HTML

    #option-1 {
      color: red;
    }
    #option-2 {
      color: green;
    }
    
    #option-3 {
      color: yellow;
    }
    
    #option-4 {
      color: blue;
    }
    <select>
      <option id="option-1">Option 1</option>
      <option id="option-2">Option 2</option>
      <option id="option-3">Option 3</option>
      <option id="option-4">Option 4</option>
    </select>

    0 讨论(0)
  • 2020-12-20 14:33

    here is what you want Styling Dropdown Lists

        <style type="text/css">
        option.red {background-color: #cc0000; font-weight: bold; font-size: 12px;}
        option.pink {background-color: #ffcccc;}
        </style>
    
        <select name=colors>
        <option class="red" value= "../getting_started/">Getting Started </option>
        <option class="pink" value= "../getting_started/html_intro1.htm">- Intro to HTML
         </option>
        </select>

    0 讨论(0)
  • 2020-12-20 14:37

    I guess you mean a select? This should work:

    option:nth-child(1) { background: green; }
    option:nth-child(2) { background: blue; }
    

    etc

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