【问题标题】:MaterializeCSS Select Background ColorMaterializeCSS 选择背景颜色
【发布时间】:2021-02-27 01:54:58
【问题描述】:

我尝试了 MaterializeCSS 选择的背景颜色。我尝试使用这个问题,但它不适用于Change select box option background color,因为它适用于常规 HTML(无 Materialise)。

我该怎么做?

【问题讨论】:

    标签: html css materialize


    【解决方案1】:

    这与 Materialize 的选择器有关。下面的代码对我有用:

    <link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css" rel="stylesheet"/>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
    <div class="input-field col s12">
        <select class="select1">
            <option value="1" selected>Option 1</option>
            <option value="2">Option 2</option>
            <option value="3">Option 3</option>
        </select>
        <label>Materialize Select</label>
    </div>
    <style>
      input.select-dropdown {
          background: #1A1B1C !important;
          color: #26a69a;
      }
      ul.dropdown-content.select-dropdown li span {
          background: #1A1B1C; 
      }
    </style>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            var elems = document.querySelectorAll('select');
            var instances = M.FormSelect.init(elems);
        });
    </script>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-10-13
      • 2018-03-04
      • 2018-10-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-19
      相关资源
      最近更新 更多