JSFiddle - React, Tailwind, and code Playground
by Jerry Peng
HTML
<body>
<header id="header">
<nav>
<ul id="main">
<li><a href="#">Home</a>
</li>
<li> <a href="#">About</a>
<ul class="hidden">
<li><a href="#">About 1</a>
</li>
<li><a href="#">About 2</a>
</li>
<li><a href="#">About 3</a>
</li>
</ul>
</li>
<li> <a href="#">Services</a>
<ul class="hidden">
<li><a href="#">Services 1</a>
</li>
<li><a href="#">Services 2</a>
</li>
<li><a href="#">Services 3</a>
</li>
</ul>
</li>
<li> <a href="#">History</a>
<ul class="hidden">
<li><a href="#">The History of This Site</a>
</li>
<li><a href="#">The History of The Web</a>
</li>
<li><a href="#">The History of Whatever</a>
</li>
</ul>
</li>
<li><a href="#">Contact</a>
</li>
</ul>
</nav>
</header>
</body>
CSS
body {
margin:0;
padding:0;
height:1000px;
background: #39a;
font-family:arial;
}
header {
z-index:2;
position: fixed;
width: 100%;
height: 60px;
background: #222;
}
nav {
float:left;
}
nav ul {
list-style-type:none;
margin:0;
padding:0;
}
nav ul li {
display:inline-block;
float:left;
}
nav ul li a {
display:block;
width:80px;
height:60px;
text-align:center;
text-decoration:none;
line-height:60px;
color:white;
background:#404040;
}
nav ul li a:hover {
background:darkgray;
}
nav ul li:hover ul {
display:block;
}
nav ul li:hover ul a {
background:#404040;
color:white;
height:60px;
line-height:60px;
}
ul.hidden {
display:none;
position:absolute;
border-top:white solid 2px;
}
ul.hidden li {
display:block;
float:none;
}
ul.hidden li a {
width:auto;
min-width:80px;
padding:0 20px;
}
ul.hidden li a:hover {
background:darkgray;
}
JavaScript
$(document).ready(function () {
var width = $(window).width();
if (width > 800) {
$('ul li').hover(function () {
$('ul.hidden'.this).filter(':not(:animated)').slideDown(500);
},
function () {
$('ul.hidden'
this).fadeOut(500);
});
}
});