Bootsrap 4 Dropdown未显示下拉菜单中的所有链接

时间:2017-11-08 06:24:43

标签: javascript css html5 twitter-bootstrap bootstrap-4

bootstrap 4下拉菜单未显示下拉菜单中的所有链接,请参阅图片

enter image description here

它没有显示超出红色乐队,是否有一些我想念的东西无法弄明白



.red-block{
  height: 220px;
  background-color: red;
}

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
        <div class="container-fluid no-padding mt-3">
      <div class="row no-gutter">
        <div class="col-md-6">
          <div class="red-block ">
             <div class="title">
                <div class="light-title text-uppercase ml-20 mr-5 pt-5 ">
                   <h4 class="text-left">our <span>Services</span></h4>
                   <hr class="light" align="left" style="width:22%;">
                 </div>
                 </div>
                 <div class="dropdown ml-20">
                  <button type="button" class="btn btn-secondary text-uppercase dropdown-toggle" data-toggle="dropdown">
                    State
                  </button>
                    <ul class="dropdown-menu">
                    <li><a class="dropdown-item" href="#">Link 1</a></li>
                    <li><a class="dropdown-item" href="#">Link 2</a></li>
                    <li><a class="dropdown-item" href="#">Link 3</a></li>
                  </ul>
                </div>
          </div>
        </div>

<!-- begin snippet: js hide: false console: true babel: false -->
&#13;
&#13;
&#13;

**

所以链接3不可见,有人能纠正这个吗?

3 个答案:

答案 0 :(得分:0)

你能提出你的完整代码吗?无论如何,请尝试我的代码,看看它是否有帮助。我已将你的div和锚替换为ul - li - anchor结构。

让我知道它是否有帮助。

    <!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title></title>
  <meta name="author" content="">
  <meta name="description" content="">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
  <script src="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
  <link rel="stylesheet" type="text/css" href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
</head>
<body>
  <div class="dropdown ml-20">
   <button type="button" class="btn btn-secondary text-uppercase dropdown-toggle" data-toggle="dropdown">
     State
   </button>
     <ul class="dropdown-menu">
     <li><a class="dropdown-item" href="#">Link 1</a></li>
     <li><a class="dropdown-item" href="#">Link 2</a></li>
     <li><a class="dropdown-item" href="#">Link 3</a></li>
   </ul>
 </div>
</body>
</html>

答案 1 :(得分:0)

尝试在css中添加此内容。

我不知道这会在您的html文件中有效。

.dropdown-menu{
  postition: relative;
  z-index:-1
}

答案 2 :(得分:0)

有时,当您尝试在overflow: hidden的容器/元素之外显示元素时会发生这种情况 例如:

.red-block{
  overflow: hidden;
  background-color: red;
  height: 220px;
}

您可以做的是1.检查是否有任何overflow: hidden元素并更改它或2.将.dropdown元素移到div.red-block旁边,就像这样:

HTML

     <div class="container-fluid no-padding mt-3">
      <div class="row no-gutter">
        <div class="col-md-6">
          <!-- RED BLOCK -->
          <div class="red-block ">
            <div class="title">
              <div class="light-title text-uppercase ml-20 mr-5 pt-5 ">
                <h4 class="text-left">our <span>Services</span></h4>
                <hr class="light" align="left" style="width:22%;">
              </div>
            </div>
          </div>
          <!-- END RED BLOCK 
           DROPDOWN -->
          <div class="dropdown ml-20">
              <button type="button" class="btn btn-secondary text-uppercase dropdown-toggle" data-toggle="dropdown">
                State
              </button>
              <ul class="dropdown-menu">
                <li><a class="dropdown-item" href="#">Link 1</a></li>
                <li><a class="dropdown-item" href="#">Link 2</a></li>
                <li><a class="dropdown-item" href="#">Link 3</a></li>
              </ul>
            </div>
        </div>
<!-- END DROPDOWN -->

CSS

.red-block{
  background-color: red;
  height: 220px;
}
.dropdown.ml-20{
   position: absolute;
    bottom: 25%;
}

希望有所帮助