对不起,我对这个东西不太喜欢,并且已经研究了一段时间的全球导航并且不足。我的全局导航工作,但代码不会样式。以下是我的设置:
我的.html文件中的导航部分:
<!-- Navigation -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- 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>
</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">
<nav id="myNav">
<script src="js/load_essentials.js"></script>
</nav>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
.js文件如下所示:
document.getElementById("myNav").innerHTML =
"<ul id='navLinks'>"
+ "<li><a href='blahblahblah.html'>Back</a></li>"
+ "<li><a href='blahblahblah.html'>Home</a></li>"
+ "<li><a href='blahblahblah.html'>Reviews</a></li>"
"</ul>";
我做错了什么不能让它采取我的风格?
答案 0 :(得分:0)
尝试将此类'nav navbar-nav'
添加到js文件中的ul
元素。
JS
document.getElementById("myNav").innerHTML =
"<ul id='navLinks' class='nav navbar-nav'>"
+ "<li><a href='blahblahblah.html'>Back</a></li>"
+ "<li><a href='blahblahblah.html'>Home</a></li>"
+ "<li><a href='blahblahblah.html'>Reviews</a></li>"
"</ul>";
并使用window.onload
希望这有助于......