我是Bootstrap的新手,正在尝试创建navbar,但没有成功。我什至没有试图在其中添加任何项目。我只是在尝试添加公司/品牌的名称。我已经买了一个在线课程,那里的老师使用了相同的代码,并且对他有用。
这是代码。请通过以下帮助我:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Navbar is cool!</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-default">
<div class="navbar-header">
<a href="#">Google</a>
</div>
</nav>
</body>
</html>
答案 0 :(得分:0)
请改用此代码...
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Google</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
</ul>
</div>
</nav>
</body>
</html>
答案 1 :(得分:0)
如果您只想在Navbar中添加一个引用,则可以这样做::
<nav class="navbar navbar-light bg-light">
<a class="navbar-brand" href="#">Google</a>
</nav>
也许这是您正在寻找的代码。 检查:https://jsfiddle.net/sugandhnikhil/frcvu2d8/