html - Bootstrap 4 导航栏下拉问题

标签 html css twitter-bootstrap bootstrap-4

我试图将这个导航栏下拉菜单分成两列,但它们相互冲突。

另一个问题是,在移动设备中搜索栏停留在底部。并且页面没有响应。不知道是不是导航栏的问题。任何输入将不胜感激。希望大家周末愉快!

html {
  position: relative;
  min-height: 100%;
}
body {
  margin-bottom: 60px;

}








 section {
     padding: 70px 0;
     border-bottom: 1px dotted #ccc;
}
 .grid-example div[class^="col"] {
     border: 1px solid white;
     background: lightblue;
     text-align: center;
     padding-top: 8px;
     padding-bottom: 8px;
}
 .jumbotron {
     background-color: lightskyblue;
}
 table th {
     text-align: center;
}
 .table {
     margin: auto;
     width: 50% !important;
}
 .table td {
     text-align: center;
}
 .footer {
     position: absolute;
     bottom: 0;
     width: 100%;
     height: 60px;
     line-height: 60px;
     color: #fff;
     text-align: center;
     background-color: #C0C0C0;
}
 a {
     color: #f00;
}
 a:hover {
     color: #0f0;
}
<!doctype html>
<html lang="en">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Test</title>
    <meta name="description" content="Test">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <link rel="stylesheet" href="Sticky Footer.css">

    


   

</head>

<body>

    <nav class="navbar-expand-sm navbar-expand-md navbar-expand-lg navbar navbar-light" style="background-color: #C0C0C0;">
        <a class="navbar-brand" href="#">Navbar</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNavDropdown">
            <ul class="navbar-nav">
                <li class="nav-item active">
                    <a class="nav-link" href="#">Test <span class="sr-only">(current)</span></a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">Test</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">Test</a>
                </li>
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          Test
        </a>
                    <div class="dropdown-menu" style="width:300px" aria-labelledby="navbarDropdown">
                        <div class="container container-sm">
                            <div class="row">
                                <div class="col-sm-4">
                                    <a class="dropdown-item" href="#">Test Test Test</a>
                                    <a class="dropdown-item" href="#">Test Test</a>
                                    <a class="dropdown-item" href="#">Test</a>
                                </div>
                                <div class="col-sm-4">
                                    <a class="dropdown-item" href="#">itemitemitemitem</a>
                                    <a class="dropdown-item" href="#">itemitemitemitemitem</a>
                                    <a class="dropdown-item" href="#">item</a>
                                </div>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </nav>


<div class="jumbotron">
  <h1 class="display-8">Hello, world!</h1>
  <p class="lead-8">This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.</p>
  
  <p class="lead">
    <a class="btn btn-primary btn-md" href="#" role="button">Learn more</a>
  </p>
</div>









    <div class="row align-items-center" style="min-height: calc(100vh - 500px);">
        <div class="col-xs-3 col-sm-8 col-md-6 col-lg-6 mx-auto">
            <div class="input-group-prepend">

                <input id='urlurl' type="url" class="form-control" placeholder="Search" pattern="https?://.+" required />
                <span class="input-group-btn">
                    <button class="btn btn-primary" style="background-color: #0275D8; border-color: #0275D8;" type="button" >Test</button>
                </span>
            </div>
        </div>
    </div>




    <footer class="footer fixed-bottom text-center">
        <span class="text">Place sticky footer content here.</span>
    </footer>



    <!-- jQuery Version 1.11.1 -->
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>






</body>

</html>

最佳答案

我将回答与标题相关的下拉问题。 您不想在下拉列表中嵌套 container。同时增加下拉菜单中的 min-width 以适应内容。

https://www.codeply.com/go/9wUCwUErKL

       <div class="dropdown-menu" style="min-width:360px" aria-labelledby="navbarDropdown">
                <div class="row no-gutters">
                    <div class="col-sm-6">
                        <a class="dropdown-item px-2" href="#">Test Test Test</a>
                        <a class="dropdown-item px-2" href="#">Test Test</a>
                        <a class="dropdown-item px-2" href="#">Test</a>
                    </div>
                    <div class="col-sm-6">
                        <a class="dropdown-item px-2" href="#">itemitemitemitem</a>
                        <a class="dropdown-item px-2" href="#">itemitemitemitemitem</a>
                        <a class="dropdown-item px-2" href="#">item</a>
                    </div>
                </div>
       </div>

在 Bootstrap 4 中不再有 col-xs-*,只有 col-*

关于html - Bootstrap 4 导航栏下拉问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49456982/

相关文章:

jQuery 为什么代码使用 .animate() 函数运行两次?

javascript - 如何在HTML5网页中将数据保存在本地,这样我们就不需要一次又一次地从服务器获取?

html - 样式输入类型=数字

html - Bootstrap 4 使行固定高度并连接

html - 达到小尺寸时网格无法正确堆叠

html - 让 Bootstrap 下拉选择选项与文本字段内联

html - 无法更改菜单栏中的图像 "onhover"?

html - 使用 Bootstrap 4 在小型设备上进行页脚布局、响应和隐藏

javascript - 在页面加载事件中更改现有 DOM 元素时避免闪烁

php - 事件 div 的可能代码