W3.CSS

TRANG CHỦ W3.CSS Giới thiệu W3.CSS W3.CSS Màu sắc Vùng chứa W3.CSS Bảng điều khiển W3.CSS Biên giới W3.CSS Thẻ W3.CSS W3.CSS Mặc định Phông chữ W3.CSS W3.CSS Google Văn bản W3.CSS Vòng W3.CSS W3.CSS Padding Lề W3.CSS Màn hình W3.CSS Các nút W3.CSS W3.CSS Ghi chú Báo giá W3.CSS Cảnh báo W3.CSS Bảng W3.CSS Danh sách W3.CSS Hình ảnh W3.CSS Đầu vào W3.CSS Huy hiệu W3.CSS Thẻ W3.CSS Biểu tượng W3.CSS W3.CSS đáp ứng Bố cục W3.CSS W3.CSS Animations Hiệu ứng W3.CSS Thanh W3.CSS W3.CSS thả xuống Hiệp định W3.CSS Điều hướng W3.CSS Thanh bên W3.CSS Các tab W3.CSS Phân trang W3.CSS Thanh tiến trình W3.CSS Trình chiếu W3.CSS Phương thức W3.CSS W3.CSS Tooltip W3.CSS Grid Mã W3.CSS Bộ lọc W3.CSS Xu hướng W3.CSS Trường hợp W3.CSS Vật liệu W3.CSS Xác thực W3.CSS Phiên bản W3.CSS W3.CSS Mobile

W3.CSS Màu sắc

Các lớp màu W3.CSS Chất liệu màu W3.CSS Giao diện người dùng phẳng màu W3.CSS Giao diện người dùng Metro màu W3.CSS W3.CSS màu Win8 W3.CSS Color iOS W3.CSS Màu thời trang Thư viện màu W3.CSS Lược đồ màu W3.CSS Chủ đề màu W3.CSS Máy tạo màu W3.CSS

Xây dựng Web

Giới thiệu web HTML web CSS web JavaScript trên web Bố trí trang web Băng tần web Dịch vụ ăn uống trên web Nhà hàng web Kiến trúc sư web

Các ví dụ

Ví dụ về W3.CSS Bản trình diễn W3.CSS W3.CSS Mẫu

Người giới thiệu

Tham chiếu W3.CSS Tải xuống W3.CSS

Thanh bên W3.CSS



W3.CSS Thanh điều hướng dọc

Với điều hướng bên, bạn có một số tùy chọn:

  • Luôn hiển thị ngăn điều hướng bên trái nội dung trang
  • Sử dụng điều hướng bên đáp ứng "hoàn toàn tự động" có thể thu gọn
  • Mở ngăn điều hướng ở phần bên trái của nội dung trang
  • Mở ngăn điều hướng trên tất cả nội dung trang
  • Trượt nội dung trang sang phải khi mở ngăn điều hướng
  • Hiển thị ngăn điều hướng ở bên phải thay vì bên trái

Luôn hiển thị thanh bên

Thí dụ

<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>


Mở Điều hướng Thanh bên Qua một phần Nội dung

Thí dụ

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

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

Mở Điều hướng Thanh bên Qua Nội dung

Thí dụ

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

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

Điều hướng bên có trách nhiệm có thể thu gọn

Thí dụ

<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>

Trượt nội dung trang sang phải

Thí dụ

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";
}

Điều hướng bên phải

Thí dụ

<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>

Điều hướng có thể thu gọn bên phải

Thí dụ

<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>

Điều hướng bên trái & bên phải

Thí dụ


Tạo kiểu cho Điều hướng bên

Thêm lớp màu w3 vào thanh bên w3 để thay đổi màu nền. Nếu bạn muốn một liên kết đang hoạt động / hiện tại, để cho người dùng biết họ đang truy cập trang nào, hãy thêm lớp màu w3 vào một trong các liên kết:

Thí dụ

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

Điều hướng bên có viền

Sử dụng lớp w3-border để thêm đường viền xung quanh điều hướng bên:

Thí dụ

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

Thêm lớp w3-border-bottom vào các liên kết để tạo các bộ phân chia liên kết:

Thí dụ

<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>

Sử dụng lớp thẻ w3 để hiển thị điều hướng bên dưới dạng thẻ:

Thí dụ

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

Liên kết có thể lưu trữ

Khi bạn di chuột qua các liên kết bên trong một khối thanh, màu nền sẽ chuyển thành màu xám.

Nếu bạn muốn có một màu nền khác khi di chuột, hãy sử dụng bất kỳ lớp màu nào của w3-hover-color :

Thí dụ

<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>

Bạn có thể tắt hiệu ứng di chuột mặc định với lớp w3-hover-none . Điều này thường được sử dụng khi bạn chỉ muốn đánh dấu màu văn bản (chứ không phải màu nền) khi di chuột:

Thí dụ

<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>

Kích thước điều hướng bên

Tăng kích thước phông chữ (w3-lớn, v.v.):

Tăng đệm (w3-padding, v.v.):

Thí dụ

<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>

Điều hướng bên với các biểu tượng

Thí dụ

<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>

Thanh bên có menu thả xuống

Thí dụ

<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>