Pasek boczny W3.CSS



W3.CSS Pionowe paski nawigacyjne

Dzięki nawigacji bocznej masz kilka opcji:

  • Zawsze wyświetlaj panel nawigacji po lewej stronie zawartości strony
  • Użyj składanej, „w pełni automatycznej” responsywnej nawigacji bocznej
  • Otwórz panel nawigacyjny nad lewą częścią zawartości strony
  • Otwórz panel nawigacji na całej zawartości strony
  • Przesuń zawartość strony w prawo podczas otwierania okienka nawigacji
  • Wyświetl okienko nawigacyjne po prawej stronie zamiast po lewej stronie

Zawsze wyświetlaj pasek boczny

Przykład

<div class="w3-sidebar w3-bar-block" style="width:25%">
  <a href="#" class="w3-bar-item w3-button">Link 1</a>
  <a href="#" class="w3-bar-item w3-button">Link 2</a>
  <a href="#" class="w3-bar-item w3-button">Link 3</a>
</div>

<div style="margin-left:25%">
... page content ...
</div>


Otwórz nawigację paska bocznego nad częścią zawartości

Przykład

function w3_open() {
  document.getElementById("mySidebar").style.display = "block";
}

function w3_close() {
  document.getElementById("mySidebar").style.display = "none";
}

Otwórz nawigację paska bocznego nad zawartością

Przykład

function w3_open() {
  document.getElementById("mySidebar").style.width = "100%";
  document.getElementById("mySidebar").style.display = "block";
}

function w3_close() {
  document.getElementById("mySidebar").style.display = "none";
}

Składana responsywna nawigacja po stronie

Przykład

<div class="w3-sidebar w3-bar-block w3-collapse w3-card" style="width:200px;" id="mySidebar">
  <button class="w3-bar-item w3-button w3-hide-large"
  onclick="w3_close()">Close &times;</button>
  <a href="#" class="w3-bar-item w3-button">Link 1</a>
  <a href="#" class="w3-bar-item w3-button">Link 2</a>
  <a href="#" class="w3-bar-item w3-button">Link 3</a>
</div>

<div class="w3-main" style="margin-left:200px">

<div class="w3-teal">
  <button class="w3-button w3-teal w3-xlarge" onclick="w3_open()">&#9776;</button>
  <div class="w3-container">
    <h1>My Page</h1>
  </div>
  </div>
</div>

<script>
function w3_open() {
  document.getElementById("mySidebar").style.display = "block";
}

function w3_close() {
  document.getElementById("mySidebar").style.display = "none";
}
</script>

Przesuń zawartość strony w prawo

Przykład

function w3_open() {
  document.getElementById("main").style.marginLeft = "25%";
  document.getElementById("mySidebar").style.width = "25%";
  document.getElementById("mySidebar").style.display = "block";
  document.getElementById("openNav").style.display = 'none';
}

function w3_close() {
  document.getElementById("main").style.marginLeft = "0%";
  document.getElementById("mySidebar").style.display = "none";
  document.getElementById("openNav").style.display = "inline-block";
}

Nawigacja po prawej stronie

Przykład

<div class="w3-sidebar w3-bar-block" style="width:25%;right:0">
  <h5 class="w3-bar-item">Menu</h5>
  <a href="#" class="w3-bar-item w3-button">Link 1</a>
  <a href="#" class="w3-bar-item w3-button">Link 2</a>
  <a href="#" class="w3-bar-item w3-button">Link 3</a>
</div>

<div style="margin-right:25%">
... page content ...
</div>

Składana nawigacja po prawej stronie

Przykład

<div class="w3-sidebar w3-bar-block w3-collapse" style="width:200px;right:0" id="mySidebar">
  <button class="w3-bar-item w3-button w3-hide-large"
  onclick="w3_close()">Close &times;</button>
  <a href="#" class="w3-bar-item w3-button">Link 1</a>
  <a href="#" class="w3-bar-item w3-button">Link 2</a>
  <a href="#" class="w3-bar-item w3-button">Link 3</a>
</div>

<div class="w3-main" style="margin-right:200px">
<div class="w3-teal">
  <button class="w3-button w3-teal w3-xlarge w3-right w3-hide-large" onclick="w3_open()">&#9776;</button>
  <div class="w3-container">
    <h2>My Page</h2>
  </div>
</div>

</div>

<script>
function w3_open() {
  document.getElementById("mySidebar").style.display = "block";
}

function w3_close() {
  document.getElementById("mySidebar").style.display = "none";
}
</script>

Nawigacja po lewej i prawej stronie

Przykład


Stylizacja bocznej nawigacji

Dodaj klasę kolorów w3 do paska bocznego w3, aby zmienić kolor tła. Jeśli chcesz mieć aktywny/bieżący link, aby użytkownik wiedział, na której stronie się znajduje, dodaj również klasę w3 color do jednego z linków:

Przykład

<div class="w3-sidebar w3-red">

Obramowana boczna nawigacja

Użyj klasy w3-border , aby dodać obramowanie wokół bocznej nawigacji:

Przykład

<div class="w3-sidebar w3-border">

Dodaj klasę w3-border-bottom do łączy, aby utworzyć dzielniki łączy:

Przykład

<div class="w3-sidebar w3-bar-block">
  <a href="#" class="w3-bar-item w3-button w3-border-bottom">Link 1</a>
  <a href="#" class="w3-bar-item w3-button w3-border-bottom">Link 2</a>
  <a href="#" class="w3-bar-item w3-button">Link 3</a>
</div>

Użyj klasy w3-card , aby wyświetlić nawigację boczną jako kartę:

Przykład

<nav class="w3-sidebar w3-card">

Hoverable Linki

Gdy najedziesz myszą na linki wewnątrz bloku paska, kolor tła zmieni się na szary.

Jeśli chcesz mieć inny kolor tła po najechaniu myszą, użyj dowolnej z klas w3-hover-color :

Przykład

<div class="w3-sidebar w3-bar-block">
  <a href="#" class="w3-bar-item w3-button w3-hover-black">Link 1</a>
  <a href="#" class="w3-bar-item w3-button w3-hover-green">Link 2</a>
  <a href="#" class="w3-bar-item w3-button w3-hover-blue">Link 3</a>
</div>

Możesz wyłączyć domyślny efekt najechania za pomocą klasy w3-hover-none . Jest to często używane, gdy chcesz tylko podświetlić kolor tekstu (a nie kolor tła) po najechaniu myszą:

Przykład

<div class="w3-sidebar w3-bar-block">
  <a href="#" class="w3-bar-item w3-button w3-hover-none w3-hover-text-grey">Link 1</a>
  <a href="#" class="w3-bar-item w3-button w3-hover-none w3-hover-text-green">Link 2</a>
  <a href="#" class="w3-bar-item w3-button w3-hover-none w3-hover-text-teal">Link 3</a>
</div>

Rozmiary nawigacji bocznej

Zwiększony rozmiar czcionki (w3 duży itp.):

Zwiększona wyściółka (w3 padding itp.):

Przykład

<div class="w3-sidebar w3-bar-block w3-large">
  <a href="#" class="w3-bar-item w3-button">Link</a>
  <a href="#" class="w3-bar-item w3-button">Link</a>
  <a href="#" class="w3-bar-item w3-button">Link</a>
</div>

Nawigacja boczna z ikonami

Przykład

<div class="w3-sidebar w3-bar-block w3-black" style="width:70px">
  <a href="#" class="w3-bar-item w3-button"><i class="fa fa-home"></i></a>
  <a href="#" class="w3-bar-item w3-button"><i class="fa fa-search"></i></a>
  <a href="#" class="w3-bar-item w3-button"><i class="fa fa-envelope"></i></a>
  <a href="#" class="w3-bar-item w3-button"><i class="fa fa-globe"></i></a>
</div>

Pasek boczny z menu rozwijanym

Przykład

<div class="w3-sidebar w3-bar-block">
  <a href="#" class="w3-bar-item w3-button">Link 1</a>
  <a href="#" class="w3-bar-item w3-button">Link 2</a>
  <div class="w3-dropdown-hover">
    <button class="w3-button">Dropdown <i class="fa fa-caret-down"></i></button>
    <div class="w3-dropdown-content w3-bar-block">
      <a href="#" class="w3-bar-item w3-button">Link</a>
      <a href="#" class="w3-bar-item w3-button">Link</a>
    </div>
  </div>
<a href="#" class="w3-bar-item w3-button">Link 3</a>
</div>

Tip: When the dropdown menu is "open", the dropdown link gets a grey background color to indicate that it is active. To override this, add a w3-hover-color class to both the "dropdown" <div> and <a>.


Sidebar with Accordion

Example

<div class="w3-sidebar w3-light-grey w3-card" style="width:200px">
  <a href="#" class="w3-bar-item w3-button">Link 1</a>
  <button class="w3-button w3-block w3-left-align" onclick="myAccFunc()">Accordion</button>
  <div id="demoAcc" class="w3-bar-block w3-hide w3-white w3-card-4">
    <a href="#" class="w3-bar-item w3-button">Link</a>
    <a href="#" class="w3-bar-item w3-button">Link</a>
  </div>
  <div class="w3-dropdown-click">
    <button class="w3-button" onclick="myDropFunc()">Dropdown</button>
    <div id="demoDrop" class="w3-dropdown-content w3-bar-block w3-white w3-card-4">
      <a href="#" class="w3-bar-item w3-button">Link</a>
      <a href="#" class="w3-bar-item w3-button">Link</a>
    </div>
  </div>
  <a href="#" class="w3-bar-item w3-button">Link 2</a>
  <a href="#" class="w3-bar-item w3-button">Link 3</a>
</div>


Animated Sidebar

Use any of the w3-animate-classes to fade, zoom or slide in side navigation:

Example

<div class="w3-sidebar w3-animate-left">

Sidebar Overlay

The w3-overlay class can be used to create an overlay effect when opening the sidebar. The w3-overlay class adds a black background with a 50% opacity to the "page content" - this effect will "highlight" the side navigation.

Example

<!-- Sidebar -->
<div class="w3-sidebar w3-bar-block" style="display:none;z-index:5" id="mySidebar">
  <button class="w3-bar-item w3-button" onclick="w3_close()">Close</button>
  <a href="#" class="w3-bar-item w3-button">Link 1</a>
  <a href="#" class="w3-bar-item w3-button">Link 2</a>
  <a href="#" class="w3-bar-item w3-button">Link 3</a>
</div>

<!-- Overlay -->
<div class="w3-overlay" onclick="w3_close()" style="cursor:pointer" id="myOverlay"></div>

<!-- Page content -->
<button class="w3-button w3-xxlarge" onclick="w3_open()">&#9776;</button>
<div class="w3-container">
  <h1>Sidebar Overlay</h1>
  <p>Click on the "hamburger" icon to slide in the side navigation.</p>
</div>

<!-- JS to open and close sidebar with overlay effect -->
<script>
function w3_open() {
  document.getElementById("mySidebar").style.display = "block";
  document.getElementById("myOverlay").style.display = "block";
}

function w3_close() {
  document.getElementById("mySidebar").style.display = "none";
  document.getElementById("myOverlay").style.display = "none";
}
</script>

Sidebar Content

Add whatever you like inside the side navigation:

Example

<div class="w3-sidebar w3-bar-block w3-light-grey" style="width:50%">
  <div class="w3-container w3-dark-grey">
    <h4>Menu</h4>
  </div>

  <img src="img_snowtops.jpg">

  <a href="#" class="w3-bar-item w3-button w3-red">Home</a>
  <a href="#" class="w3-bar-item w3-button">Projects
    <span class="w3-tag w3-red w3-round w3-right">8</span>
  </a>
  <a href="#" class="w3-bar-item w3-button">About</a>
  <a href="#" class="w3-bar-item w3-button">Contact</a>

  <div class="w3-panel w3-blue-grey w3-display-container">
    <span class="w3-button w3-display-topright">X</span>
    <p>Lorem ipsum box...</p>
  </div>
 </div>