如何在bootstrap 4中删除选择选项背景?

时间:2018-04-29 03:42:50

标签: css bootstrap-4

enter image description here

这是我的导航栏图片。我想删除选择选项的背景和边框。并在两个选择选项和搜索栏之间放置一些空格。我怎样才能做到这一点?您可以选择建议如何在导航栏中水平对齐项目?

<div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav mr-auto">
            <li class="nav-item active">
                <a class="nav-link" href="test.php"><i class="fa fa-home">Home</i><span class="sr-only">(current)</span></a>
            </li>

            <form class="form-inline"  action="./test.php?id=1" method="POST">
                <li class="nav-item">
                    <div class="form-group">
                        <select class="custom-select custom-select-lg mb-3"  name="objectType">
                          <option selected>Object Type</option>
                          <option value="Toy">Toy</option>
                          <option value="Furniture">Furniture</option>
                          <option value="Gift">Gift</option>
                          <option value="Household">Household</option>
                          <option value="Instrument">Instrument</option>
                        </select>
                    </div>
                </li>


                <li class="nav-item">
                    <div class="form-group">
                        <select class="custom-select custom-select-lg mb-3" name="materialType">
                          <option selected>Material Type</option>
                          <option value="Mud">Mud</option>
                          <option value="Cloth">Cloth</option>
                          <option value="Thread">Thread</option>
                          <option value="Jute">Jute</option>
                          <option value="Cotton">Cotton</option>
                          <option value="Can">Can</option>
                          <option value="Bamboo">Bamboo</option>
                        </select>
                    </div>
                </li>


                <li class="nav-item">
                    <div class="form-group">
                        <div class="input-group">
                            <input class="form-control" type="search" placeholder="Search" name="imageName">
                            <span class="input-group-btn">
                                <button class="btn btn-outline-secondary" type="submit" id="searchSubmit"><i class="fa fa-search"></i>
                                </button>
                            </span>
                        </div>
                    </div>
                </li>
            </form>

对于完整导航栏newnavbar.php

2 个答案:

答案 0 :(得分:1)

表示边框,边距和背景:

.custom-select {
  border: none;
  margin-right: 10px;
  background-color: transparent;
}

这是一个小提琴:https://jsfiddle.net/takius/ghwe204k/

答案 1 :(得分:0)

这是我的解决方案..

使用bootstarp 4实用程序类 - “ml-1”(margin-left:.25)或“mr-1”(margin-right:.25)在列表项之间留出空格。

<li class="nav-item ml-1"></li>

对于select,请添加此css: -

select{
  background: none;
  border: none;
}