W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap 实例</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <div class="container mt-3"> <h3>彩色导航栏</h3> <p>请使用任何 .bg-color 类来更改导航栏的背景颜色:</p> <p>提示:请使用 .navbar-dark 类为导航栏中的所有链接添加白色文本颜色,或使用 .navbar-light 类添加黑色文本颜色。</p> </div> <nav class="navbar navbar-expand-sm bg-light navbar-light"> <div class="container-fluid"> <ul class="navbar-nav"> <li class="nav-item"> <a class="nav-link active" href="#">活动</a> </li> <li class="nav-item"> <a class="nav-link" href="#">链接</a> </li> <li class="nav-item"> <a class="nav-link" href="#">链接</a> </li> <li class="nav-item"> <a class="nav-link disabled" href="#">禁用</a> </li> </ul> </div> </nav> <nav class="navbar navbar-expand-sm bg-dark navbar-dark"> <div class="container-fluid"> <ul class="navbar-nav"> <li class="nav-item"> <a class="nav-link active" href="#">活动</a> </li> <li class="nav-item"> <a class="nav-link" href="#">链接</a> </li> <li class="nav-item"> <a class="nav-link" href="#">链接</a> </li> <li class="nav-item"> <a class="nav-link disabled" href="#">禁用</a> </li> </ul> </div> </nav> <nav class="navbar navbar-expand-sm bg-primary navbar-dark"> <div class="container-fluid"> <ul class="navbar-nav"> <li class="nav-item"> <a class="nav-link active" href="#">活动</a> </li> <li class="nav-item"> <a class="nav-link" href="#">链接</a> </li> <li class="nav-item"> <a class="nav-link" href="#">链接</a> </li> <li class="nav-item"> <a class="nav-link disabled" href="#">禁用</a> </li> </ul> </div> </nav> <nav class="navbar navbar-expand-sm bg-success navbar-dark"> <div class="container-fluid"> <ul class="navbar-nav"> <li class="nav-item"> <a class="nav-link active" href="#">活动</a> </li> <li class="nav-item"> <a class="nav-link" href="#">链接</a> </li> <li class="nav-item"> <a class="nav-link" href="#">链接</a> </li> <li class="nav-item"> <a class="nav-link disabled" href="#">禁用</a> </li> </ul> </div> </nav> <nav class="navbar navbar-expand-sm bg-info navbar-dark"> <div class="container-fluid"> <ul class="navbar-nav"> <li class="nav-item"> <a class="nav-link active" href="#">活动</a> </li> <li class="nav-item"> <a class="nav-link" href="#">链接</a> </li> <li class="nav-item"> <a class="nav-link" href="#">链接</a> </li> <li class="nav-item"> <a class="nav-link disabled" href="#">禁用</a> </li> </ul> </div> </nav> <nav class="navbar navbar-expand-sm bg-warning navbar-dark"> <div class="container-fluid"> <ul class="navbar-nav"> <li class="nav-item"> <a class="nav-link active" href="#">活动</a> </li> <li class="nav-item"> <a class="nav-link" href="#">链接</a> </li> <li class="nav-item"> <a class="nav-link" href="#">链接</a> </li> <li class="nav-item"> <a class="nav-link disabled" href="#">禁用</a> </li> </ul> </div> </nav> <nav class="navbar navbar-expand-sm bg-danger navbar-dark"> <div class="container-fluid"> <ul class="navbar-nav"> <li class="nav-item"> <a class="nav-link active" href="#">活动</a> </li> <li class="nav-item"> <a class="nav-link" href="#">链接</a> </li> <li class="nav-item"> <a class="nav-link" href="#">链接</a> </li> <li class="nav-item"> <a class="nav-link disabled" href="#">禁用</a> </li> </ul> </div> </nav> <nav class="navbar navbar-expand-sm bg-secondary navbar-dark"> <div class="container-fluid"> <ul class="navbar-nav"> <li class="nav-item"> <a class="nav-link active" href="#">活动</a> </li> <li class="nav-item"> <a class="nav-link" href="#">链接</a> </li> <li class="nav-item"> <a class="nav-link" href="#">链接</a> </li> <li class="nav-item"> <a class="nav-link disabled" href="#">禁用</a> </li> </ul> </div> </nav> </body> </html>