Selasa, 08 Maret 2016

CSS Navbar

CSS Navbar

1. contoh pertama:






Script :
<!DOCTYPE html>
<html>
<head>
<style>
ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: blue;
}

li {
    float: right;
}

li a {
    display: inline-block;
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
}

li a:hover {
    background-color: #111;
}
</style>
</head>
<body>

<ul>
  <li><a class="active" href="#beranda">Beranda</a></li>
  <li><a href="#berita">Berita</a></li>
  <li><a href="#contact">Contact</a></li>
  <li><a href="#about">About</a></li>
</ul>

</body>
</html>

Note Kita bisa menentukan tata letak yang kita inginkan dengan mengubah float, misalkan saya ubah float: right; menjadi float: left;
Nah, hasilnya akan menjadi seperti gambar di atas








2.
script :



<!DOCTYPE html>
<html>
<head>
<style>
ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: blue;
}

li {
    float: left;
    border-right:1px solid #bbb;
}

li:last-child {
    border-right: none;
}

li a {
    display: block;
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
}

li a:hover:not(.active) {
    background-color: #111;
}

.active {
    background-color: black;
}
</style>
</head>
<body>

<ul>
  <li><a href="#home">Home</a></li>
  <li><a class="active" href="#news">News</a></li>
  <li><a href="#contact">Contact</a></li>
  <li style="float:right"><a href="#about">About</a></li>
</ul>

</body>
</html>


0 komentar:

Posting Komentar

Twitter Delicious Facebook Digg Stumbleupon Favorites More