- Dapatkan pautan
- X
- E-mel
- Apl Lain
Contoh
HTML view ▼
<div class="navbar">
<a href="https://orandableg.blogspot.com/">LAMAN UTAMA</a>
<a href="https://orandableg.blogspot.com/p/iklan-oleh-google.html">ULAS IKLAN</a>
<div class="dropdown">
<button class="dropbtn" onclick="myFunction()">BAWAHLABUH
</button>
<div class="dropdown-content" id="myDropdown">
<a href="https://orandableg.blogspot.com/2010/03/">Catatan terawal</a>
<a href="https://orandableg.blogspot.com/search/label/bagaimana">#Bagaimana</a>
<a href="#">Link 3 (kosong)</a>
</div>
</div>
</div>
<style>
.navbar {
overflow: hidden;
background-color: #b45f06;
font-family: Arial, Helvetica;
}
.navbar a {
float: left;
font-size: 16px;
color: white;
text-align: center;
padding: 12px 20px;
text-decoration: none;
}
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
cursor: pointer;
font-size: 16px;
border: none;
outline: none;
color: #ffffff;
padding: 12px 20px;
background-color: inherit;
font-family: inherit;
margin: 0;
}
.navbar a:hover, .dropdown:hover .dropbtn, .dropbtn:focus {
background-color: #3d85c6;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #ffffff;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
float: none;
color: #333333;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown-content a:hover {
background-color: #ddd;
}
.show {
display: block;
}
</style>
<script>
function myFunction() {
document.getElementById("myDropdown").classList.toggle("show");
}
window.onclick = function(e) {
if (!e.target.matches('.dropbtn')) {
var myDropdown = document.getElementById("myDropdown");
if (myDropdown.classList.contains('show')) {
myDropdown.classList.remove('show');
}
}
}
</script>
<a href="https://orandableg.blogspot.com/">LAMAN UTAMA</a>
<a href="https://orandableg.blogspot.com/p/iklan-oleh-google.html">ULAS IKLAN</a>
<div class="dropdown">
<button class="dropbtn" onclick="myFunction()">BAWAHLABUH
</button>
<div class="dropdown-content" id="myDropdown">
<a href="https://orandableg.blogspot.com/2010/03/">Catatan terawal</a>
<a href="https://orandableg.blogspot.com/search/label/bagaimana">#Bagaimana</a>
<a href="#">Link 3 (kosong)</a>
</div>
</div>
</div>
<style>
.navbar {
overflow: hidden;
background-color: #b45f06;
font-family: Arial, Helvetica;
}
.navbar a {
float: left;
font-size: 16px;
color: white;
text-align: center;
padding: 12px 20px;
text-decoration: none;
}
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
cursor: pointer;
font-size: 16px;
border: none;
outline: none;
color: #ffffff;
padding: 12px 20px;
background-color: inherit;
font-family: inherit;
margin: 0;
}
.navbar a:hover, .dropdown:hover .dropbtn, .dropbtn:focus {
background-color: #3d85c6;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #ffffff;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
float: none;
color: #333333;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown-content a:hover {
background-color: #ddd;
}
.show {
display: block;
}
</style>
<script>
function myFunction() {
document.getElementById("myDropdown").classList.toggle("show");
}
window.onclick = function(e) {
if (!e.target.matches('.dropbtn')) {
var myDropdown = document.getElementById("myDropdown");
if (myDropdown.classList.contains('show')) {
myDropdown.classList.remove('show');
}
}
}
</script>
Pautan dimuatkan, CSS disesuaikan untuk paparan di blog ini, dipetik dari W3schools
Ulasan