我通过bootstrap构建了一个导航栏,我在下拉菜单中遇到了问题。
第一个:
1.目前尚未公开。
2.我希望下拉菜单中的文字正确。
这是导航栏的完整代码:
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>דף הבית</title>
<style>
@media only screen and (max-width: 500px) {
.img {
position: relative;
top: -50px;
left: -40px;
}
}
</style>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<!--JQuery.min.js------------>
<script src="http://code.jquery.com/jquery.min.js"></script>
<!--JQuery.min.js------------>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="style.css" rel="stylesheet">
</head>
<body>
<header>
<nav class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"/>
<span class="icon-bar"/>
<span class="icon-bar"/>
</button>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active navbar-right">
<a href="index.html">דף הבית</a>
</li>
<li class="navbar-right">
<a href="about_me.html">אודות</a>
</li>
<li class="navbar-right">
<a href="contact.html">צור קשר</a>
</li>
<li class="dropdown navbar-right">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
aria-expanded="false">
לקוחותינו
<span class="caret"/>
</a>
<ul class="dropdown-menu">
<li><a href="#">דואר ישראל</a></li>
<li><a href="#">בנק הפועלים</a></li>
<li><a href="#">בנק לאומי</a></li>
<li role="separator" class="divider"/>
<li class="dropdown-header">עבודות מוכנות</li>
<li><a href="#">זובי</a></li>
<li><a href="#">עוד זובי</a></li>
</ul>
</li>
</ul>
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="חיפוש">
</div>
<button type="submit" class="btn btn-default">חפש</button>
</form>
</div>
</div>
</nav>
答案 0 :(得分:0)
您的图标切换按钮未关闭<span class="icon-bar"></span>
,请参阅CSS以调整右侧的文字。
@media (min-width: 768px) {
.navbar-default .dropdown-menu > li {
text-align: right;
}
}
@media only screen and (max-width: 500px) {
.img {
position: relative;
top: -50px;
left: -40px;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>
</button>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active navbar-right"> <a href="index.html">דף הבית</a>
</li>
<li class="navbar-right"> <a href="about_me.html">אודות</a>
</li>
<li class="navbar-right"> <a href="contact.html">צור קשר</a>
</li>
<li class="dropdown navbar-right"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
לקוחותינו
<span class="caret"/>
</a>
<ul class="dropdown-menu">
<li><a href="#">דואר ישראל</a>
</li>
<li><a href="#">בנק הפועלים</a>
</li>
<li><a href="#">בנק לאומי</a>
</li>
<li role="separator" class="divider" />
<li class="dropdown-header">עבודות מוכנות</li>
<li><a href="#">זובי</a>
</li>
<li><a href="#">עוד זובי</a>
</li>
</ul>
</li>
</ul>
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="חיפוש">
</div>
<button type="submit" class="btn btn-default">חפש</button>
</form>
</div>
</div>
</nav>