Bootstrap3 导航条之个人学习笔记

Bootstrap3 导航条

标签(空格分隔): Bootstrap

默认的导航条

使用Bootstrap主要是使用一些它定义好的样式类,所以做笔记就简单点,把一些样式类记下来,看参考代码基本就能用,详细学习参考官方文档

效果图:
Bootstrap3 导航条之个人学习笔记_第1张图片

参考代码:


<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
   <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js">script>
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js">script>
    <style> body { padding-top: 70px; padding-bottom: 70px; } style>
    <title>导航条title>
head>

<body>
    <nav class="navbar navbar-default" role="navigation">
        <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 navigationspan>
                <span class="icon-bar">span>
                <span class="icon-bar">span>
                <span class="icon-bar">span>
            button>
            <a class="navbar-brand" href="#">Branda>
        div>
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li class="active"><a href="#">Linka>li>
                <li><a href="#">Linka>li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret">b>a>
                    <ul class="dropdown-menu">
                        <li><a href="#">Actiona>li>
                        <li><a href="#">Another actiona>li>
                        <li><a href="#">Something else herea>li>
                        <li class="divider">li>
                        <li><a href="#">Separated linka>li>
                        <li class="divider">li>
                        <li><a href="#">One more separated linka>li>
                    ul>
                li>
            ul>
            <form class="navbar-form navbar-left" role="search">
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="Search">
                div>
                <button type="submit" class="btn btn-default">Submitbutton>
            form>
            <ul class="nav navbar-nav navbar-right">
                <li><a href="#">Linka>li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret">b>a>
                    <ul class="dropdown-menu">
                        <li><a href="#">Actiona>li>
                        <li><a href="#">Another actiona>li>
                        <li><a href="#">Something else herea>li>
                        <li class="divider">li>
                        <li><a href="#">Separated linka>li>
                    ul>
                li>
            ul>
        div>
    nav>
    <hr>

    
    <nav class="navbar navbar-default" role="navigation">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-2">
                <span class="sr-only">Toggle navigationspan>
                <span class="icon-bar">span>
                <span class="icon-bar">span>
                <span class="icon-bar">span>
            button>
            <a class="navbar-brand" href="#">Branda>
        div>
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-2">
            <ul class="nav navbar-nav">
                <li class="active"><a href="#">Linka>li>
                <li><a href="#">Linka>li>
                <li class="dropdown">
                    <a href="#" class="dropdown dropdown-toggle" data-toggle="dropdown">
                        Dropdown <b class="caret">b>
                    a>
                    <ul class="dropdown-menu">
                        <li><a href="#">Actiona>li>
                        <li><a href="#">Actiona>li>
                        <li><a href="#">Actiona>li>
                        <li class="divider">li>
                        <li><a href="#">Separated linka>li>
                        <li class="divider">li>
                        <li><a href="#">One more separated linka>li>
                    ul>
                li>
            ul>
            <form action="" class="navbar-form navbar-left" role="search">
                <div class="form-group">
                    <label for="" class="sr-only">labellabel>
                    <input type="text" class="form-control" placeholder="Search">
                div>
                <button type="submit" class="btn btn-default">Submitbutton>
            form>
            <ul class="nav navbar-nav navbar-right">
                <li><a href="#">Linka>li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        Dropdown <b class="caret">b>
                    a>
                    <ul class="dropdown-menu">
                        <li><a href="#">Actiona>li>
                        <li><a href="#">Actiona>li>
                        <li><a href="#">Actiona>li>
                        <li><a href="#">Actiona>li>
                    ul>
                li>
            ul>
        div>
    nav>
<hr>
    <p class="navbar-text">Signed in as Mark Ottop>
    <p class="navbar-text navbar-right">Signed in as <a href="#" class="navbar-link">Mark Ottoa>p>
<hr>

<hr>
    
    <nav class="navbar navbar-default navbar-inverse navbar-fixed-top" role="navigation">
        <form action="" class="navbar-form navbar-left" role="search">
            <div class="form-group">
                <input type="text" class="form-control" placeholder="Search">
            div>
            <button type="submit" class="btn btn-default">Submitbutton>
        form>
        <button type="button" class="btn btn-default navbar-btn">Sign inbutton>
    nav>
body>

html>

2.2 表单

navbar-form form-inline

2.3 按钮

navbar-btn

2.4 文本

navbar-text

2.5 非导航的链接

navbar-link

2.6 组件对齐

navbar-left navbar-right pull-left pull-right

2.7 固定在顶部、底部

navbar-fixed-top navbar-fixed-bottom
body {padding-top: 70px;} body {padding-bottom: 70px;}

一定要在加载 Bootstrap CSS 的核心后使用它。

2.9 静止在顶部

.navbar-static-top

navbar-fixed-* 不同,不用给body加padding

2.10 反色的导航条

navbar-inverse

你可能感兴趣的:(Bootstrap)