在bootstrap下拉列表中删除白线

时间:2018-06-14 19:01:09

标签: html css twitter-bootstrap

我创建了一个带引导程序的导航栏,下拉菜单的顶部和底部都有一条白线。我希望整个下拉列表颜色相同,但似乎无法弄清楚如何摆脱白线。顺便说一句,我是一名初学者编码器,这个导航栏是直接复制并粘贴在getboostrap上,所以如果有什么不对劲请告诉我,谢谢! Here is a picture of the dropdown

这是我的HTML:

<nav class="navbar navbar-expand-lg navbar-dark" style="background-color:#3d3d3d">
<a class="navbar-brand" href="https://marginedge.com/" target="_blank">
  <img src="navbarLogo.png" width="200">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
  <ul class="navbar-nav mr-auto">
    <li class="nav-item active">
      <a class="nav-link" href="#">Flow <span class="sr-only">(current) 
</span></a>
    </li>
    <li class="nav-item">
      <a class="nav-link" href="#">Map</a>
    </li>
    <li class="nav-item">
      <a class="nav-link" href="#">EDI Tracker</a>
    </li>
    <li class="nav-item">
      <a class="nav-link" href="#">D.C. Sales</a>
    </li>
    <li class="nav-item">
      <a class="nav-link" href="#">Zendesk</a>
    </li>
    <li class="nav-item dropdown">
      <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      Client Facing
    </a>
      <div class="dropdown-menu" aria-labelledby="navbarDropdown">
        <a class="dropdown-item" href="#">Isabella</a>
        <a class="dropdown-item" href="#">Eggspectation</a>
        <a class="dropdown-item" href="#">Ford's</a>
        <a class="dropdown-item" href="#">Hard Rock</a>
        <a class="dropdown-item" href="#">Wendy's</a>
      </div>
    </li>
    <li class="nav-item">
      <a class="nav-link" href="#">Demos</a>
    </li>
    <li class="nav-item dropdown">
      <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      Analyst
    </a>
      <div class="dropdown-menu" aria-labelledby="navbarDropdown">
        <a class="dropdown-item" href="#">IR Error Report</a>
        <a class="dropdown-item" href="#">Rec Error Report</a>
        <a class="dropdown-item" href="#">Quarterly Team Evaluations</a>
        <a class="dropdown-item" href="#">Data Fixer for Analysts</a>
      </div>
    </li>
    <li class="nav-item">
      <a class="nav-link" href="#">Redash</a>
    </li>
    <li class="nav-item">
      <a class="nav-link" href="#">Central Data Health Check</a>
    </li>
  </ul>
  <form class="form-inline my-2 my-lg-0">
    <input class="form-control mr-lg-2" type="search" size="40" placeholder="Search Redash Reports..." aria-label="Search">
    <button type="button" class="btn btn-outline-primary btn-lg">Search</button>
  </form>
</div>

这里是CSS:

body{
padding: 0;
margin: 0;
}
nav {
width: 100%;
}
nav ul li{
padding: 5px 10px;
font-size: 20px;
}
.dropdown-menu a{
font-size: 15px;
color: #d6d6d6;
background-color: #3d3d3d;
}

1 个答案:

答案 0 :(得分:0)

在.dropdown-menu上添加p-0课程。它将删除填充导致白色空间

&#13;
&#13;
body {
  padding: 0;
  margin: 0;
}

nav {
  width: 100%;
}

nav ul li {
  padding: 5px 10px;
  font-size: 20px;
}

.dropdown-menu a {
  font-size: 15px;
  color: #d6d6d6;
  background-color: #3d3d3d;
}
&#13;
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<nav class="navbar navbar-expand-lg navbar-dark" style="background-color:#3d3d3d">
  <a class="navbar-brand" href="https://marginedge.com/" target="_blank">
    <img src="navbarLogo.png" width="200">
  </a>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
  <div class="collapse navbar-collapse" id="navbarSupportedContent">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item active">
        <a class="nav-link" href="#">Flow <span class="sr-only">(current) 
</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Map</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">EDI Tracker</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">D.C. Sales</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Zendesk</a>
      </li>
      <li class="nav-item dropdown">
        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  Client Facing
</a>
        <div class="dropdown-menu p-0" aria-labelledby="navbarDropdown">
          <a class="dropdown-item" href="#">Isabella</a>
          <a class="dropdown-item" href="#">Eggspectation</a>
          <a class="dropdown-item" href="#">Ford's</a>
          <a class="dropdown-item" href="#">Hard Rock</a>
          <a class="dropdown-item" href="#">Wendy's</a>
        </div>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Demos</a>
      </li>
      <li class="nav-item dropdown">
        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  Analyst
</a>
        <div class="dropdown-menu p-0" aria-labelledby="navbarDropdown">
          <a class="dropdown-item" href="#">IR Error Report</a>
          <a class="dropdown-item" href="#">Rec Error Report</a>
          <a class="dropdown-item" href="#">Quarterly Team Evaluations</a>
          <a class="dropdown-item" href="#">Data Fixer for Analysts</a>
        </div>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Redash</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Central Data Health Check</a>
      </li>
    </ul>
    <form class="form-inline my-2 my-lg-0">
      <input class="form-control mr-lg-2" type="search" size="40" placeholder="Search Redash Reports..." aria-label="Search">
      <button type="button" class="btn btn-outline-primary btn-lg">Search</button>
    </form>
  </div>
&#13;
&#13;
&#13;