如何解决我的引导程序导航栏面临的这3个问题:
这是一个演示:
https://jsfiddle.net/whywymam/zpdpsuLn/
HTML代码:
<div class="container">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<navbar>
<div class="upperRow">
<div class="navbar-header">
<a href="#" class="brand navbar-brand"> <img src="image/logo.png" class="img-responsive"></a>
</div>
<div id="btnTopInline">
<ul class="nav navbar-nav navbar-right imgicon hidden-xs">
<li>
<div class="indivColl">
<a href="signupLogin.php">
<img src="image/jobseekerlogo.png" class="indi">
<p class="indit">Job Seeker</p>
</a>
</div>
</li>
<li>
<div id="empColl">
<a href="signupLoginEmp.php">
<img src="image/employerlogo.png" class="emp">
<p class="empt">Employer</p>
</a>
</div>
</li>
</ul>
</div>
<!-- for tablet and mobile view-->
<button type="button" class="btn btn-login pull-right visible-xs">
<a href="signupLoginEmp.php">
Employer<br>Log In
</a>
</button>
<button type="button" class="btn btn-login pull-right visible-xs">
<a href="signupLogin.php">
Job Seeker<br>Log In
</a>
</button>
</div>
<div class="middleRow">
<div class="navbar-inner navbar-default navbar-static-top navcolor">
<div class="navbar-header ">
<!--button to appear when display is on mobile device-->
<button type="button" class="navbar-toggle pull-right" data-toggle="collapse" data-target=".nav-collapse">
<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 class="nav-collapse collapse-in" id="nav-collapse">
<ul class="nav navbar-nav center-block">
<li><a href="home.php">Home<img src="image/home.png" width="75" height="65" alt="" title="" /></a></li>
<li><a href="about.php">About<img src="image/about.png" width="75" height="65" alt="" title="" /></a></li>
<li><a href="pyw.php">Prove Job<img src="image/PYW.png" width="75" height="65" alt="" title="" /></a></li>
<li><a href="#">Job<img src="image/jobs.png" width="75" height="65" alt="" title="" /></a></li>
<li><a href="rescources.php">Resources<img src="image/resource.png" width="75" height="65" alt="" title="" /></a></li>
</ul>
</div>
</div> <!-- end inner navbar -->
</div> <!-- end middle row -->
</navbar>
</div> <!-- end col-lg-12 col-md-12 col-sm-12 col-xs-12 -->
</div><!-- end container -->
CSS:
.img-responsive {
max-width: 60%;
margin-bottom: 15%;
padding-top: -3%;
}
.imgicon {
padding-left: 50%;
margin-top: -2%;
}
.middleRow{
padding-top: 10%;
margin-top: 5%;
}
.navcolor{
background-color: transparent;
}
.navbar-default {
margin-top: 3%;
}
.navbar-nav {
float:none;
margin: 0 auto;
display: table;
table-layout: fixed;
text-align: center;
}
#btnTopInline{
display: inline-block;
float: right;
clear: none;
}
@media(min-width:768px) {
.nav-collapse{
display: inline;
}
}
提前谢谢你:)
答案 0 :(得分:2)
以下是我在html和css中进行了一些修改的代码
让toggal按钮使用data-target=".nav-collapse"
data-target=".navbar-collapse"
对于菜单链接旁边的图标,在ancor标签内添加img标签。
以下是更改
<body>
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<div class="navbar-header">
<a href="#" class="brand navbar-brand"> <img src="image/logo.png" class="img-responsive"></a>
</div>
<ul class="nav navbar-nav navbar-right imgicon hidden-xs">
<div id="indivColl">
<a href="signupLogin.php">
<img src="image/jobseekerlogo.png" class="indi">
<p class="indit">Job Seeker</p>
</a>
</div>
<div id="empColl">
<a href="signupLoginEmp.php">
<img src="image/employerlogo.png" class="emp">
<p class="empt">Employer</p>
</a>
</div>
</ul>
<!-- for tablet and mobile view-->
<button type="submit" id="btn-login-header" class="btn btn-login pull-right visible-xs mobile-login"
id="header-mobile-login-button" data-target="#indivColl">
Employer<br>Log In
</button>
<button type="submit" id="btn-login-header" class="btn btn-login pull-right visible-xs mobile-login"
id="header-mobile-login-button" data-target="#empColl">
Job Seeker<br>Log In
</button>
<button type="button" class="navbar-toggle btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="nav-collapse collapse in" id="navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="home.php">Home<img src="image/home.png" width="75" height="65" alt="" title="" /></a></li>
<li><a href="about.php">About<img src="image/about.png" width="75" height="65" alt="" title="" /></a></li>
<li><a href="pyw.php">Prove Your Worth<img src="image/PYW.png" width="75" height="65" alt="" title="" /></a></li>
<li><a href="#">Job<img src="image/jobs.png" width="75" height="65" alt="" title="" /></a></li>
<li><a href="rescources.php">Resources<img src="image/resource.png" width="75" height="65" alt="" title="" /></a></li>
</ul>
</div>
</div>
</div>
</div>
</body>
在css中添加此内容
@media(min-width:768px) {
.nav-collapse{
display: block;
}
}
答案 1 :(得分:0)
首先:对于响应式布局工作,引导程序需要使用行和列。你需要将导航栏放在里面。
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<navbar>
</navbar>
</div>
</div>
第二:我没有测试,但我认为在导航栏的里面你需要创建一个包含text-align:center的类的div;或者把这个班级放在里面。在div内部放置文本和图标,每个都有一个类,包含float:left和clear:both。
<ul class="nav navbar-nav navbar-right imgicon hidden-xs">
<div id="indivColl">
<a href="signupLogin.php"><img src="image/jobseekerlogo.png" class="indi"><p class="indit">Job Seeker</p></a>
</div>
<div id="empColl">
<a href="signupLoginEmp.php"><img src="image/employerlogo.png" class="emp"><p class="empt">Employer</p></a>
</div>
</ul>
上面你需要将每个div放在里面。在img中插入类并将p标记交换到span标记,然后将相同的类添加到span。 这个例子是一个假设,我没有测试,但你可以在www.w3cschools.com上搜索关于浮动的更多信息并清除
代码中导航栏的逻辑完全错误。导航栏内有一个带有两个容器的导航栏。你需要回顾一下bootstrap,html和css dude的概念!与你的比较:
<div class="navbar navbar-default navbar-static-top navcolor">
<div class="navbar-header">
<a href="#" class="navbar-brand"> <img src="image/logo.png" class="img-responsive"></a>
</div>
<!-- for tablet and mobile view-->
<button type="submit" id="btn-login-header" class="btn btn-login pull-right navbar-btn visible-xs mobile-login" id="header-mobile-login-button" data-target="#indivColl"> Job Seeker Log In </button>
<button type="submit" id="btn-login-header" class="btn btn-login pull-right navbar-btn visible-xs mobile-login" id="header-mobile-login-button" data-target="#empColl"> Employer Log In </button>
<div class="navbar-header">
<!--button to appear when display is on mobile device-->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<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 class="collapse navbar-collapse" id="navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="home.php">Home</a><img src="image/home.png" width="75" height="65" alt="" title="" /></li>
<li><a href="about.php">About</a><img src="image/about.png" width="75" height="65" alt="" title="" /></li>
<li><a href="pyw.php">Prove Your Worth</a><img src="image/PYW.png" width="75" height="65" alt="" title="" /></li>
<li><a href="#">Job</a><img src="image/jobs.png" width="75" height="65" alt="" title="" /></li>
<li><a href="rescources.php">Resources</a><img src="image/resource.png" width="75" height="65" alt="" title="" /></li>
<li class="imgicon hidden-xs">
<div id="indivColl">
<a href="signupLogin.php"><img src="image/jobseekerlogo.png" class="indi"><p class="indit">Job Seeker</p></a>
</div>
</li>
<li class="imgicon hidden-xs">
<div id="empColl">
<a href="signupLoginEmp.php"><img src="image/employerlogo.png" class="emp"><p class="empt">Employer</p></a>
</div>
</li>
</ul>
</div>
我没有用css或完全引导规则输入细节,但我认为这段代码对你有用。并没有忘记浮动和清除^^
的类这将是一种方法。再见,就像我的回答一样,如果送达!