创建默认的引导导航栏
在Bootstrap中按照以下给定步骤创建默认导航栏-
将.navbar,.navbar-default类添加到<nav>标记。
在上面的元素中添加role=“navigation”,以帮助辅助功能。
将头文件类.navbar-header添加到<div>元素。在navbar-brand类中包含一个<a>元素。这将使文本略大。
要将链接添加到导航栏,只需添加具有.nav,.navbar-nav类的无序列表即可。
您可以尝试运行以下代码来创建默认导航栏-
示例
<!DOCTYPE html> <html> <head> <title>Bootstrap Example</title> <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet"> <script src = "/scripts/jquery.min.js"></script> <script src = "/bootstrap/js/bootstrap.min.js"></script> </head> <body style = "background: #F5CBA7;"> <nav class = "navbar navbar-default" role = "navigation"> <div class = "navbar-header"> <a class = "navbar-brand" href = "#">Cars</a> </div> <div> <ul class = "nav navbar-nav"> <li class = "active"><a href = "#">BMW</a></li> <li><a href = "#">Audi</a></li> <li class = "dropdown"> <a href = "#" class = "dropdown-toggle" data-toggle = "dropdown"> SUV <b class = "caret"></b> </a> <ul class = "dropdown-menu"> <li><a href = "#">Creta</a></li> <li><a href = "#">Scorpio</a></li> </ul> </li> </ul> </div> </nav> </body> </html>