Navigation với 2 line

Trở về

  • 3,132

Navigation 2 lines, không khác hơn phần cơ bản nhiều, bằng cách xử lý thêm một hàng, giúp cho navigation thêm dạng đa dạng hơn.

Navigation – 2 dòng text

Navigation với 2 dòng text, thường là 2 ngôn ngữ hoặc dòng nội dung và dòng mô tả,…

Html viết:

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Học Web Chuẩn</title>
<style>
* { /* reset lại margin và padding cho các tag */
    margin: 0;
    padding: 0;
}
div#navigation ul { list-style: none; }
div#navigation ul li {
    float: left;
}
div#navigation ul li a {
    color: #333;
    border-left: 1px solid #333; 
    display: block;
    padding: 0 15px;
    text-decoration: underline;
}
div#navigation ul li a strong {
    color: blue;
}
div#navigation ul li a:hover {
    text-decoration: none;
}
div#navigation ul li.naviLast a {
    border-right: 1px solid #333;
}
.clearfix {
    zoom: 1;
}
.clearfix:after {
    clear: both;
    content: ".";
    display: block;
    height: 0;
    line-height: 0;
    visibility: hidden;
}
</style>
</head>
<body>
<div id="navigation">
<ul class="clearfix">
<li><a href="http://hocwebchuan.com"><strong>TRANG CHỦ</strong><br>Home</a></li>
<li><a href="http://hocwebchuan.com"><strong>GIỚI THIỆU</strong><br>About us</a></li>
<li><a href="http://hocwebchuan.com"><strong>SẢN PHẨM</strong><br>Products</a></li>
<li><a href="http://hocwebchuan.com"><strong>DỊCH VỤ</strong><br>Service</a></li>
<li class="naviLast"><a href="http://hocwebchuan.com"><strong>LIÊN HỆ</strong><br>Contact</a></li>
</ul>
</div>
</body>
</html>

Hiển thị trình duyệt:

 

clearfix là thủ thuật được dùng kèm với thuộc tính float, bạn có thể xem thêm về clearfix ở phần hướng dẫn học.

Download file để thực hành

Navigation 2 dòng text với các border xung quanh.

Html viết:

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Học Web Chuẩn</title>
<style>
* { /* reset lại margin và padding cho các tag */
    margin: 0;
    padding: 0;
}
div#navigation ul { list-style: none; }
div#navigation ul li {
    float: left;
}
div#navigation ul li a {
    color: #333;
    border: 1px solid #333;
    border-right: none;
    display: block;
    padding: 7px 15px 5px;
    text-decoration: none;
}
div#navigation ul li a strong {
    color: blue;
}
div#navigation ul li a:hover {
    background-color: #e0fcdd;
}
div#navigation ul li.naviLast a {
    border-right: 1px solid #333;
}
.clearfix {
    zoom: 1;
}
.clearfix:after {
    clear: both;
    content: ".";
    display: block;
    height: 0;
    line-height: 0;
    visibility: hidden;
}
</style>
</head>
<body>
<div id="navigation">
<ul class="clearfix">
<li><a href="http://hocwebchuan.com"><strong>TRANG CHỦ</strong><br>Home</a></li>
<li><a href="http://hocwebchuan.com"><strong>GIỚI THIỆU</strong><br>About us</a></li>
<li><a href="http://hocwebchuan.com"><strong>SẢN PHẨM</strong><br>Products</a></li>
<li><a href="http://hocwebchuan.com"><strong>DỊCH VỤ</strong><br>Service</a></li>
<li class="naviLast"><a href="http://hocwebchuan.com"><strong>LIÊN HỆ</strong><br>Contact</a></li>
</ul>
</div>
</body>
</html>

Hiển thị trình duyệt:

 

Thay đổi cách dùng border và sử dụng thêm margin, ta sẽ có một dạng khác của navigation.

Html viết:

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Học Web Chuẩn</title>
<style>
* { /* reset lại margin và padding cho các tag */
    margin: 0;
    padding: 0;
}
div#navigation ul { list-style: none; }
div#navigation ul li {
    float: left;
}
div#navigation ul li a {
    color: #333;
    border: 1px solid #333;
    display: block;
    margin-right: 3px;
    padding: 7px 15px 5px;
    text-decoration: none;
}
div#navigation ul li a strong {
    color: blue;
}
div#navigation ul li a:hover {
    background-color: #e0fcdd;
}
.clearfix {
    zoom: 1;
}
.clearfix:after {
    clear: both;
    content: ".";
    display: block;
    height: 0;
    line-height: 0;
    visibility: hidden;
}
</style>
</head>
<body>
<div id="navigation">
<ul class="clearfix">
<li><a href="http://hocwebchuan.com"><strong>TRANG CHỦ</strong><br>Home</a></li>
<li><a href="http://hocwebchuan.com"><strong>GIỚI THIỆU</strong><br>About us</a></li>
<li><a href="http://hocwebchuan.com"><strong>SẢN PHẨM</strong><br>Products</a></li>
<li><a href="http://hocwebchuan.com"><strong>DỊCH VỤ</strong><br>Service</a></li>
<li><a href="http://hocwebchuan.com"><strong>LIÊN HỆ</strong><br>Contact</a></li>
</ul>
</div>
</body>
</html>

Hiển thị trình duyệt:

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.