我正在努力为我的导航栏使用bootstrap框架。
一旦我开始自定义桌面版,移动版(已折叠)就不再显示为下拉式移动菜单。
当我花费它时,它看起来就像我的桌面菜单。
我认为这是一个简单的解决方案,但我已经研究了一段时间而且无法弄清楚。
<head>
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<link href="http://fonts.googleapis.com/css?family=Pacifico" rel="stylesheet" type="text/css">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="portfolio.css">
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" 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> <a class="navbar-brand" href="#">Brand</a>
</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 class="active"><a href="#">Portfolio</a>
</li>
<li><a href="#">Credentials</a>
</li>
<li><a href="#">Resume</a>
</li>
<li><a href="#">Mentions</a>
</li>
<li><a href="#">Contact</a>
</li>
</ul>
</li>
</ul>
</div>
</nav>
/* --- Style --- */
/* navbar */
.navbar-default {
height: 90px;
background-color: #F5F5F5;
border-color: #D6D6D6;
text-align: center;
}
.navbar-default .navbar-nav {
margin: 0;
display: table;
width: 100%;
}
.navbar-default .navbar-nav li {
display: table-cell;
width: 13%;
float: none;
}
/* title */
.navbar-default .navbar-brand {
font: 30px 'Pacifico', Helvetica, sans-serif;
font-style: normal;
color: #616161;
text-shadow: 1.5px 1.5px 0px rgba(0, 0, 0, 0.1), 0.5px 0.5px 0px rgba(0, 0, 0, 0.05);
padding-top: 20px;
}
.navbar-default .navbar-brand:hover,
.navbar-default .navbar-brand:focus {
font: 30px 'Pacifico', Helvetica, sans-serif;
font-style: normal;
color: green;
text-shadow: 1.5px 1.5px 0px rgba(0, 0, 0, 0.1), 0.5px 0.5px 0px rgba(0, 0, 0, 0.05);
}
/* link */
.navbar-default .navbar-nav > li > a {
font-family: Open Sans, sans-serif;
font-size: 20px;
color: #3B3B3B; /* inactive link text color */
text-align: center;
padding-top: 3px;
}
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
color: #3B3B3B; /* active link text color */
font-weight: 600;
background-color: #F5F5F5; /* inactive link bg color */
box-shadow: inset 0px -6px 0px #EBEBEB; /* switch to a darker color on hover */
padding-top: 3px;
}
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
color: #3B3B3B;
font-weight: 600;
background-color: #F5F5F5;
box-shadow: inset 0px -6px 0px 0px #00FFFF; /* switch to a lighter color for active element */
padding-top: 3px;
}
.navbar-default .navbar-nav > .open > a,
.navbar-default .navbar-nav > .open > a:hover,
.navbar-default .navbar-nav > .open > a:focus {
color: blue;
background-color: red;
padding-top: 3px;
}
}
/* mobile version */
.navbar-default .navbar-toggle {
border-color: blue;
}
.navbar-default .navbar-toggle:hover,
.navbar-default .navbar-toggle:focus {
background-color: red;
}
.navbar-default .navbar-toggle .icon-bar {
background-color: green;
}
@media (max-width: 767px) {
.navbar-default .navbar-nav .open .dropdown-menu > li > a {
color: red;
}
.navbar-default .navbar-nav .open .dropdown-menu > li > a:hover,
.navbar-default .navbar-nav .open .dropdown-menu > li > a:focus {
color: blue;
}
}
答案 0 :(得分:0)
您好需要css媒体查询并将所需的样式放入其中。你需要什么不同?