我有一个菜单如下,但我有一些问题。例如,在全尺寸屏幕中,菜单选项不在其所在部分的中间顶部。另一个问题是,当屏幕处于手机大小和汉堡包时,我不知道如何移除黑条图标是可见的。
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"
href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script
src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</head>
<body>
<header>
<div class="container-fluid">
<div class="row">
<div class="container">
<div class="row">
<div class=" col-md-12 col-sm-12 col-xs-12 search-container">
<p>THIS IS A TEST</p>
<p>THIS IS A TEST</p>
<p>THIS IS A TEST</p>
<p>THIS IS A TEST</p>
<p>THIS IS A TEST</p>
<p>THIS IS A TEST</p>
<p>THIS IS A TEST</p>
<p>THIS IS A TEST</p>
<p>THIS IS A TEST</p>
</div>
</div>
</div>
<nav class="navbar-inverse navbar-static-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#portfolio">Portfolio</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
</div>
</nav>
</div>
</div>
</header>
</body>
</html>
答案 0 :(得分:2)
不确定中间顶部,但另一部分应该有效。
.navbar-inverse .navbar-nav > li > a:hover, .navbar-inverse .navbar-nav > li > a:focus, .navbar-inverse .navbar-nav > li > a{
padding: 10px !important;
}
.navbar-header {
background-color: white; //or inherit whatever you like
}
.navbar-toggle.collapsed {
background-color: black;
}
答案 1 :(得分:0)
使用像
这样的CSS.navbar-inverse .navbar-nav > li > a:hover, .navbar-inverse .navbar-nav > li > a:focus, .navbar-inverse .navbar-nav > li > a{
padding: 10px !important;
}
.navbar-inverse {
position: absolute;
top:50%;
width:100%;
left: 0
}
如果要删除背景颜色,请使用css
@media only screen and (max-width : 480px) {
.navbar-inverse{
background: transparent;
}
.navbar-inverse .navbar-toggle:hover, .navbar-inverse .navbar-toggle:focus{
background: transparent;
}
.navbar-inverse .navbar-toggle{
border: 0px none;
}
.navbar-inverse .navbar-toggle .icon-bar {
background: #666;
}
}
此媒体查询仅适用于移动设备屏幕
答案 2 :(得分:0)
答案 3 :(得分:0)
我已经使用bootstrap工作了很多,所以我建议你用你自己的课程扩展他们原来的风格而不是覆盖everthing。 我的sugestion基于flexbox,并使用自定义类作为根据需要使事情工作的方式。
检查一下,希望它有所帮助。 (:
JSFiddle Link:https://jsfiddle.net/ce7L0nez/
CSS:
<script>
var num = 0;
var count = 0;
while (count != 20) {
num++;
count = 0;
for (var i = 1; i <= 20; i++) {
if (num % i == 0) {
count++;
}
}
}
console.log(num);
console.log(count);
</script>
HTML:
.center-md-content {
display: flex!important;
align-items: center;
justify-content: center;
}
.center-md-content .navbar-nav {
float: none;
}
@media only screen and (max-width : 768px) {
.sm-no-background {
background-color: transparent;
}
.sm-no-background .navbar-header {
margin-left: auto;
}
.sm-no-background .navbar-toggle .icon-bar {
background-color: #333;
}
.sm-no-background .navbar-toggle {
border: 0;
}
.sm-no-background .navbar-toggle:hover .icon-bar {
background-color: #FFF;
}
}