如何更改select-tag的背景颜色?

时间:2016-08-02 09:20:04

标签: html css

我正在尝试更改下拉列表的背景颜色,我正在尝试删除border-radius。

这是HTML:

<select name="liste" class="wpcf7-form-control wpcf7-select wpcf7-validates-as-required" id="liste" aria-required="true" aria-invalid="false">
<option value="">---</option>
<option value="Brannvern og dokumentasjon">Brannvern og dokumentasjon</option>
<option value="Brannvarslingsanlegg">Brannvarslingsanlegg</option><option value="Røykvarslere">Røykvarslere</option>
</select>

这是我试过的CSS:

select#liste {
    border: 1px solid #e0e0e0 !important;
    background-color: #ffffff !important;
    border-radius: 0px !important;
    height:37px;
    line-height:37px;
    } 

但它不起作用。

这是一个jsFiddle,你可以看到我的意思:https://jsfiddle.net/5g2y8eLm/

感谢您的帮助!

4 个答案:

答案 0 :(得分:0)

对于我来说,我确实喜欢这样,并且有效:

<select class="list">
   <option>English</option>
   <option>Français</option>
</select>

CSS:

.list{color:black; background-color:azure;}

答案 1 :(得分:0)

您可以在css中使用background属性来更改背景颜色;

&#13;
&#13;
select#liste {
  border: 1px solid #e0e0e0 !important;
  background-color: #ffffff !important;
  border-radius: 0px !important;
  height: 37px;
  line-height: 37px;
  outline: none;
}
&#13;
<select id="liste">
  <option>Option 1</option>
  <option>Option 2</option>
</select>
&#13;
&#13;
&#13;

答案 2 :(得分:0)

要删除border,只需将其设置为outline: none,根据给定的示例网站,您在下拉菜单中已经有了蓝色背景。

select#liste {
    background-color: #fff;
    border-radius: 0px !important;
    height: 37px;
    line-height: 37px;
    outline: none; /*Add this*/
} 

尝试使用以下代码更改background color的{​​{1}}和color

font
select#liste {
    background-color: #111;
    border-radius: 0px !important;
    height:37px;
    line-height:37px;
    color:#fff;
    outline:none;
    } 

答案 3 :(得分:0)

结帐Setting background color of a selected HTML option element

它适用于chrome和mozilla。

他正在使用:

<select multiple="" class="form-control">
      <option>Option One</option>
      <option>Option Two</option>
      <option>Option Three</option>
      <option>Option Four</option>
      <option>Option Five</option>
</select>

select option:checked {
color: white;
background: #f26532 repeat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DxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+CiAgICAgIDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiCiAgICAgICAgICAgIHhtbG5zOmV4aWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vZXhpZi8xLjAvIj4KICAgICAgICAgPGV4aWY6UGl4ZWxYRGltZW5zaW9uPjEwMDwvZXhpZjpQaXhlbFhEaW1lbnNpb24+CiAgICAgICAgIDxleGlmOlBpeGVsWURpbWVuc2lvbj4yNDwvZXhpZjpQaXhlbFlEaW1lbnNpb24+CiAgICAgIDwvcmRmOkRlc2NyaXB0aW9uPgogICA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgqpw62IAAAAHGlET1QAAAACAAAAAAAAAAwAAAAoAAAADAAAAAwAAACWlL33IAAAAGJJREFUaAXskbEJwDAQxN4rZafsDxkgdiCtejXyF4ZrBNJ67mtPTzSwZ333zv+vgogtAF0QkGJOBTHtA7sgIMWcCmLaB3ZBQIo5FcS0D+yCgBRzKohpH9gFASnmVBDTPrAPAAAA///AaA0pAAAAbUlEQVTtk7EJgEAQBPf5IgwFQzEysyA7FuPH7DMRU0/BInSC3QqGGTYd83jLwxhIDoJp8YI4CKuHHMRBYAZgOH6Ig8AMwHD8EAeBGYDh+CEOAjMAw/nkIbmflLtBuWkV564oq66yKOoG0/E/zgOZ3EvZ0xXU/AAAAABJRU5ErkJggg==);}

对于背景数据图像,使用此data url maker将带有颜色的图像文件(对我来说是橙色图像)转换为数据网址,然后将代码粘贴到网址()

这个工作!!!。