부트스트랩에서 .nav와 .navbar의 차이점에 대한 자세한 설명

小云云
풀어 주다: 2017-12-18 11:58:09
원래의
3988명이 탐색했습니다.

내비게이션 바는 Bootstrap 웹사이트의 훌륭한 기능이자 눈에 띄는 기능입니다. 탐색 모음은 앱이나 웹사이트 탐색 헤더의 반응형 기본 구성 요소 역할을 합니다. 탐색 모음은 모바일 뷰포트에서 축소되고 사용 가능한 뷰포트 너비가 증가함에 따라 수평으로 확장됩니다. Bootstrap 탐색 모음의 핵심에는 탐색 모음에 사이트 이름과 기본 탐색 정의 스타일이 포함되어 있습니다. 이 글은 주로 부트스트랩 내비게이션 바에 있는 .nav와 .navbar의 차이점에 대한 자세한 설명을 소개하고 있습니다. 편집자는 이것이 꽤 좋다고 생각합니다. 이제 여러분에게 공유하고 참고할 수 있기를 바랍니다.

1. ul과 li로 구성된 간단한 탐색:

<ul class="nav nav-pills justify-content-center bg-dark nav-dark">
    <li class="nav-item">
      <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="nav-link">1</a>
    </li>
    <li class="nav-item">
      <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="nav-link">2</a>
    </li>
    <li class="nav-item">
      <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="nav-link">3</a>
    </li>
  </ul>

 

//解析:.nav .nav-item .nav-link表示ul li是导航——.nav-pills表示胶囊状导航——.bg-dark/.nav-dark表示黑底白字——.justify-content-center表示导航栏在浏览器上居中显示
로그인 후 복사

은 브라우저에 다음과 같이 표시됩니다.

브라우저 창이 축소되면 다음과 같이 표시됩니다.

2. 탐색 표시줄 - < ;nav> 라벨의 Class="navbar navbar-expand-sm"——

    의 class="navbar-nav"——
  • 의 class="nav-item" 코드는 다음과 같습니다.

    <nav class="navbar navbar-expand-sm bg-dark navbar-dark">
      <ul class="navbar-nav">
        <li class="nav-item active">
          <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="nav-link">link1</a>
        </li>
        <li class="nav-item">
          <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="nav-link">link1</a>
        </li>
        <li class="nav-item">
          <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="nav-link">link1</a>
        </li>
        <li class="nav-item">
          <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="nav-link">link1</a>
        </li>  
      </ul>
    </nav>
    로그인 후 복사

    일반 창 표시:

    축소된 창이 576px 미만인 경우:

    3. 탐색 모음 축소

    창이 576px 미만인 경우 단순한 프로그래밍 세로가 아닙니다. 탐색; 버튼 버튼으로 표시됩니다. 탐색 링크 숨기기, 표시하려면 버튼을 클릭하세요.

    <nav class="navbar navbar-expand-sm bg-dark navbar-dark fixed-top">
      <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="navbar-brand">
          <img src="" alt="logo" style="width:70px;height:30px;">
      </a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsible">
        <span class="navbar-toggler-icon"></span>
      </button>
      <p class="collapse navbar-collapse" id="collapsible">
      <ul class="navbar-nav">
        <li class="nav-item active">
          <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="nav-link">link1</a>
        </li>
        <li class="nav-item">
          <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="nav-link">link1</a>
        </li>
        <li class="nav-item">
          <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="nav-link">link1</a>
        </li>
        <li class="nav-item">
          <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="nav-link">link1</a>
        </li>  
      </ul>
      
    </nav>
    로그인 후 복사

    //참고: .navbar-brand는 브랜드 로고입니다.

    창이 576보다 큰 경우; , 다음과 같이 표시됩니다:

    창이 576보다 작으면 다음과 같이 표시됩니다. :

     

    4. 검색 상자를 나타내는 양식을 탐색 모음에 추가합니다. [? ? ? ? ? 】

    코드는 다음과 같습니다.

    <nav class="navbar navbar-expand-sm bg-dark navbar-dark fixed-top">
      <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="navbar-brand">
          <img src="" alt="logo" style="width:70px;height:30px;">
      </a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsible">
        <span class="navbar-toggler-icon"></span>
      </button>
      <p class="collapse navbar-collapse" id="collapsible">
      <ul class="navbar-nav">
        <li class="nav-item active">
          <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="nav-link">link1</a>
        </li>
        <li class="nav-item">
          <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="nav-link">link1</a>
        </li>
        <li class="nav-item">
          <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="nav-link">link1</a>
        </li>
        <li class="nav-item">
          <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="nav-link">link1</a>
        </li>  
      </ul>
      <form class="form-inline">
            <p class="input-group">
              <span class="input-group-addon">@</span>
              <input list="dl" type="text" class="form-control" placeholder="Search"/>
              <datalist id="dl">
                <option value="IE"></option>
                <option value="Firefox"></option>
                <option value="chrome"></option>
                <option value="safari"></option>
              </datalist>
            </p>
            
            <button class="btn btn-success" type="submit">search</button>
          </form>
    </nav>
    로그인 후 복사

    그림과 같이 네비게이션 바의 폼을 오른쪽 정렬하여 가장 오른쪽으로 이동시키는 방법은 무엇인가요? ? ? ? ? float:eight도 작동합니다. .

    emmmm....위의 해결책을 알고 있습니다. 그리드 시스템을 사용하여 왼쪽에 ul과 li를, 오른쪽에 양식을 각각 배열한 다음 Float 형식을 추가합니다.

    코드는 다음과 같습니다.

    <p class="container-fluid">
      <p class="row">
        <!-- 导航栏 -->
        <nav class="navbar fixed-top navbar-expand-sm bg-dark navbar-dark">
          <p class="col-lg-4">
          <ul class="navbar-nav">
            <li class="nav-item">
              <a class="nav-link" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >link1</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >link2</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >link3</a>
            </li>
          </ul>
          </p>
    <!-- 导航栏表单与按钮 -->
        <p class="col-lg-8">
          <form class="form-inline" style="float:right;">
            <p class="input-group">
              <span class="input-group-addon">@</span>
              <input list="dl" type="text" class="form-control" placeholder="Search"/>
              <datalist id="dl">
                <option value="IE"></option>
                <option value="Firefox"></option>
                <option value="chrome"></option>
                <option value="safari"></option>
              </datalist>
              <button class="btn btn-success" type="submit">search</button>
            </p>              
          </form>
          </p>      
        </nav>
        </p>
          </p>
    로그인 후 복사

    다들 익히셨나요? 이 글이 유용하다고 생각되면 빨리 저장해 주세요.

    관련 권장 사항:

    부트스트랩 탐색 모음 및 반응형 구현 분석

    부트스트랩 탐색 모음의 각 요소(양식, 버튼, 텍스트)를 작동하는 방법_자바스크립트 기술

    방법에 대한 자세한 설명 부트스트랩 드롭다운 검색 플러그인을 사용하세요

    위 내용은 부트스트랩에서 .nav와 .navbar의 차이점에 대한 자세한 설명의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!