我无法让导航栏工作。我从w3schools获得了导航条形码。但所有发生的事情都是它会显示导航栏,但是没有应用任何css,它看起来非常错误。 这是我的代码
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Html Editor 0.1</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<link rel="stylesheet" href="meineStyles.css"/>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">WebSiteName</a>
</div>
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">Page 1 <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Page 1-1</a></li>
<li><a href="#">Page 1-2</a></li>
<li><a href="#">Page 1-3</a></li>
</ul>
</li>
<li><a href="#">Page 2</a></li>
<li><a href="#">Page 3</a></li>
</ul>
</div>
</nav>
<br>
<div class="container jumbotron shadowdiv">
<form id ="kekform" >
<div class="row">
<div class="col-md-6">
<textarea rows="4" cols="50" class="form-control" name="comment" form="kekform" id="textarea1"
onkeyup="showUserJquery(this.value)"></textarea>
</div>
<div class="col-md-6" id="divfortext">
<div id="eindiv" style="vertical-align:top"><b id="test"></b></div>
</div>
</div>
<table>
<tr>
<td>
</td>
<td >
</td>
</tr>
<tr>
<td>
<button onclick="changeColor()" type="button" style="color: red" >Farbe ändern</button>
</td>
<td>
<input type="radio" form="kekform" value="htmlno" name="htmlenable" checked="checked" id="htmlno">
<label for="htmlno">No HTML</label>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="radio" form="kekform" value="htmlyes" name="htmlenable" id="htmlyes">
<label for="htmlyes">Yes HTML</label>
</td>
</tr>
</table>
</form>
<br> <br>
<br>
<br>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="meineScripte.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
</body>
</html>
这是一个jsfiddle,meineScripte.js
和meineStyles.css
在相应的部分。 https://jsfiddle.net/m7kq6p9q/
是的,我已经尝试过没有我自己的.js和css,但它仍然无法正常工作。如果正确加载了引导程序文件,我还使用chrome的开发人员工具进行了检查。
您可以清楚地看到导航栏看起来并不像它应该的那样。这是我从以下地方获得的:https://www.w3schools.com/bootstrap/bootstrap_navbar.asp
答案 0 :(得分:1)
使用提供的文档here,我已经能够为您创建一个工作虚拟人。
注意: W3Schools&#39; Bootstrap教程基于版本3.XX,您使用的是Bootstrap 4.0.0,因此可能存在一些兼容性问题,因此您宁愿使用Bootstrap的文档而不是W3Schools。
<强> HTML 强>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
直播示例