您知道为什么搜索图标没有显示为白色背景并且下拉菜单没有正确对齐吗?

时间:2018-11-22 19:26:03

标签: css twitter-bootstrap

我想要一种具有页眉和照片的布局,并且在页眉和页脚之间有一些带有帖子的列表项。我正在使用引导程序,我希望标题看起来像这样:

enter image description here

但它不起作用,其显示如下:https://jsfiddle.net/83vnj5ru/1/

搜索图标没有白色背景,并且“过滤器1”和“过滤器2”下拉列表未在图像中右侧对齐。你知道为什么吗?

HTML:

this.model.rate = new String(Math.round(value));

CSS:

<div class="container py-5">
  <div class="row">
    <div class="col">
      <ul class="list-group forum">
        <li class="list-group-item bg-custom-light2 py-4">
          <div class="row">
            <form class="col-5">
              <div class="form-group">
                <div class="input-group">
                  <div class="input-group-prepend">
                    <span class="input-group-text"><i class="fa fa-search"></i></span>
                  </div>
                  <input type="email" class="form-control" id="exampleInputEmail1"
                         aria-describedby="emailHelp" placeholder="Search">
                </div>
              </div>
            </form>
          </div>
          <div class="col-7 text-right">
            <div class="dropdown">
              <a class="dropdown-toggle"  id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                Filter 1
              </a>
              <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                <a class="dropdown-item" href="#">item1</a>
              </div>
            </div>
            <div class="dropdown">
              <a class="dropdown-toggle" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
              Filter 2
              </a>
              <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                <a class="dropdown-item" href="#">item1</a>
              </div>
            </div>
          </div>
        </li>
        <li class="list-group-item">list item 1</li>
        <li class="list-group-item">list item 2</li>

        <li class="list-group-item bg-custom-light2 py-4">container footer</li>
      </ul>
    </div>
  </div>
</div>

1 个答案:

答案 0 :(得分:1)

看看是否对您有帮助

.bg-custom-light2{
  background-color: #fafafa;
}
.input-group-text, .input-group-prepend{
  background-color:none;
}
.input-group-text{
  color:gray;
}

.filters{
  width: auto;
  display: inline-block;
}

.search-icon{
  background-color: #ffffff !important;
  border: 1px solid #ced4da !important;
  border-right: 1px solid transparent !important;
}

.search-input{
  border-left: 1px solid transparent !important;  
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">

<div class="container py-5">
  <div class="row">
    <div class="col">
      <ul class="list-group forum">
        <li class="list-group-item bg-custom-light2 py-4">
          <div class="row">
            <form class="col-5">
              <div class="form-group">
                <div class="input-group">
                  <div class="input-group-prepend">
                    <span class="input-group-text search-icon"><i class="fa fa-search"></i></span>
                  </div>
                  <input type="email" class="form-control search-input" id="exampleInputEmail1"
                         aria-describedby="emailHelp" placeholder="Search">
                </div>
              </div>
            </form>
          <div class="col-7 text-right">
            <div class="dropdown filters">
              <a class="dropdown-toggle"  id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                Filter 1
              </a>
              <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                <a class="dropdown-item" href="#">item1</a>
              </div>
            </div>
            <div class="dropdown filters">
              <a class="dropdown-toggle" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
              Filter 2
              </a>
              <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                <a class="dropdown-item" href="#">item1</a>
              </div>
            </div>
          </div>
        </div>
        </li>
        <li class="list-group-item">list item 1</li>
        <li class="list-group-item">list item 2</li>

        <li class="list-group-item bg-custom-light2 py-4">container footer</li>
      </ul>
    </div>
  </div>
</div>