当我将示例1200断点设置为比屏幕菜单宽度小于1200时出现的切换菜单时,如何在引导程序4中设置自定义断点。当我进入任意大小的屏幕设置切换菜单时,我想要断点。有哥们有例子请给我。
请注意,附件4会比尝试启动。
header .navbar {
background-color: #000;
}
header .navbar-light .navbar-brand {
color: #fff;
}
header .navbar-light .navbar-nav .nav-link {
color: #fff;
}
header .navbar-light .navbar-toggler {
background-color: #fff;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<header>
<nav class="navbar navbar-expand-lg navbar-light">
<a class="navbar-brand" href="#">Navbar</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="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Our Services</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
</header>
答案 0 :(得分:0)
如果要创建断点,则应使用@media查询,例如:
@media screen and (max-width: 1200px) {
header .navbar {
background-color: #000;
}
header .navbar-light .navbar-brand {
color: #fff;
}
header .navbar-light .navbar-nav .nav-link {
color: #fff;
}
header .navbar-light .navbar-toggler {
background-color: #fff;
}
}
仅当您的屏幕小于或等于1200px时才会切换
如果您想更具体地了解断点:
@media screen and (min-width: 768px) and (max-width: 1200px) {
//this will only toggle if your screen is between 1200px and 767px
}
答案 1 :(得分:0)
我希望这是您的问题的答案。无需自定义主要资产,只需使用外部内容(可折叠的导航栏)进行引导
JSfiddle:https://jsfiddle.net/fzb07qsd/
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/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.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<div class="pos-f-t">
<nav class="navbar navbar-dark bg-dark">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggleExternalContent" aria-controls="navbarToggleExternalContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</nav>
<div class="collapse" id="navbarToggleExternalContent">
<div class="bg-dark p-4">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Our Services</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</div>
</div>