CSS dropdown on hover [duplicate] - html

This question already has answers here:
CSS drop down menu hover effect
(4 answers)
Closed 8 years ago.
I'm trying to create a drop down navigation bar, this is what I've got.
html
<div class="navBar">
<ul class="navBarStyles navBarWidth navBarMain">
<li class="onSelect">Item1</li>
<li>Item2</li>
<li>Item3</li>
<ul class="navBarExtended">
<li class="borderLeft">ExtraItem</li>
</ul>
<ul class="navBarExtra" id="floatRight">
<li class="i-icon">Dropdown</li>
<ul class="dropdown">
<li>SubItem1<li>
<li>SubItem2<li>
<li>SubItem3<li>
</ul>
</ul>
</ul>
</div>
css
a{
text-decoration: none;
}
.header {
width: 100%;
background-color: #000000;
}
.headerContent{
width: 960px;
margin: 0 auto;
}
.navBar{
font-family: "opensans-regular";
width: 100%;
position: absolute;
line-height: 48px;
background-color: #0088FF; /*0088FF*/
color: #ffffff;
}
.navBarWidth{
width: 400px;
margin: 0 auto;
}
.navBarStyles li{
float: left;
}
.navBarStyles li a{
display: inline-block;
color: #FFFFFF;
font-size: .9em;
text-align: center;
padding-left: 20px;
padding-right: 20px;
vertical-align: top;
letter-spacing: 0;
text-decoration: none;
}
.navBarMain li a:hover{
background-color: #40A5FF; /*#005569 #3D3C3C 12B0CC*/
text-shadow: none;
/* Firefox */
-moz-transition-property: background-color;
-moz-transition-duration: .30s;
-moz-transition-timing-function: ease-out;
-moz-transition-delay: 0s;
/* WebKit */
-webkit-transition-property: background-color;
-webkit-transition-duration: .30s;
-webkit-transition-timing-function: ease-out;
-webkit-transition-delay: 0s;
/* Opera */
-o-transition-property: background-color;
-o-transition-duration: .30s;
-o-transition-timing-function: ease-out;
-o-transition-delay: 0s;
/* Standard */
transition-property: background-color;
transition-duration: .30s;
transition-timing-function: ease-out;
transition-delay: 0s;
}
.navBarExtended li a:hover{
text-decoration: underline;
background: none;
}
/*Class applied to current page element */
.onSelect{
background-color: #40A5FF;
}
/*Navigation Bar Extra - Sytles*/
.navBarExtra li{
float: right;
opacity: .88;
}
.navBarExtra li:hover{
opacity: 1;
background: none;
cursor: pointer;
-moz-transition-property: opacity;
-moz-transition-duration: .30s;
-moz-transition-timing-function: ease-out;
-moz-transition-delay: 0s;
}
.dropdown{
font-family: 'opensans-regular';
font-size: .95em;
}
.navBarExtra ul li{
visibility: hidden;
float: left;
min-width: 150px;
position: absolute;
margin-top: 50px;
left: 0;
z-index: 999;
}
.navBarExtra ul li:hover > ul,
.navBarExtra ul li ul:hover{
visibility: hidden;
}
jsFiddle
but not able to display the sub items under dropdown button. How can I target the dropdown button to display those when user hovers over dropdown button?

To be honest, with all the complicated class names and styles involved in your example, it's hard to work out what needs fixing. I put together a simple example that you can edit to work however you like. Should be pretty self explanatory.
See on fiddle: http://jsfiddle.net/5Uejn/23/
HTML
<ul class="navbar">
<li>page 1</li>
<li>page 2</li>
<li>title 1
<ul>
<li>page 3</li>
<li>page 4</li>
<li>page 5</li>
</ul>
</li>
<li>title 2
<ul>
<li>page 6</li>
<li>page 7</li>
</ul>
</li>
</ul>
CSS
.navbar, .navbar ul
{
font-size:20px;
list-style:none;
z-index:10;
margin:0;
padding:0;
}
.navbar a, .navbar a:link
{
color:black;
text-decoration:none;
}
.navbar li
{
float:left;
background: #666;
width:100px;
}
.navbar li:hover, .navbar a:hover
{
background:#aaa;
color:blue
}
.navbar li ul
{
display:none;
}
.navbar li:hover ul
{
position:absolute;
display:block;
width:100px;
}
.navbar li ul li
{
float:none;
}

Related

Font displays different in Chrome and in Firefox

I am a bit new when it comes to web development.
I have created a menu but its buttons width are different depending on the browser (Firefox or Chrome)
In Firefox, we can see that the end of the last button of the menu is aligned with the div below. We can also appreciate that the width of the button is 136.5px
However, in Chrome the fonts are bolder and the menu end is pushed a bit forward. Here, the width of the button is 139.281px
This is the site, the menu is on the top: http://www.metagame.gg/champions/
This is the HTML and the CSS code for the menu
.navigator {
margin: 0;
padding: 0;
display: flex;
padding-left: 39px;
background: #8C9BAA;
}
.navigator li {
display: inline-block;
position: relative;
z-index:100;
}
.navigator li a {
text-decoration: none;
font-size: 15px;
display: block;
line-height: 50px;
padding: 2px 27.75px 0px;
-webkit-transition: all 0.2s ease-in-out 0s;
-moz-transition: all 0.2s ease-in-out 0s;
-o-transition: all 0.2s ease-in-out 0s;
-ms-transition: all 0.2s ease-in-out 0s;
transition: all 0.2s ease-in-out 0s;
}
.navigator li a:hover, .navigator li:hover > a {
color:#fff;
background: #7AAFD1;
}
.navigator ul {
display: none;
margin: 0;
padding: 0;
width: 170px;
position: absolute;
left: 0px;
}
.navigator ul li {
display:block;
float: none;
background:none;
margin:0;
padding:0;
}
.navigator ul li a {
font-size:12px;
font-weight:bold;
display:block;
color:#797979;
border-left: 3px solid #ffffff;
background: #fff;
line-height: 42px;
transition: 0s;
}
.navigator ul li a:hover, .menu ul li:hover > a {
background:#EFEFEF;
border-left:3px solid #83BEE4;
color: #12303D;
}
.navigator li:hover > ul {
display: block;
}
.navigator ul ul {
left: 149px;
top: 0px;
}
#in {
color:#fff;
background: #7AAFD1;
}
.sub-menu {
border:1px solid #ddd;
border-top:0px;
border-left:0px;
box-shadow: 3px 5px 5px -5px #3B3B3B;
}
.navigatorSecond {
margin: 0;
padding: 0;
display: flex;
padding-left: 39px;
background: #d1d1d1 ;
}
.navigatorSecond li {
display: inline-block;
position: relative;
z-index:80;
}
.navigatorSecond li a {
font-weight:600;
text-decoration:none;
font-size: 13px;
display:block;
color:#4a4a4a;
line-height: 40px;
padding: 0px 35.3px;
-webkit-transition: all 0.2s ease-in-out 0s;
-moz-transition: all 0.2s ease-in-out 0s;
-o-transition: all 0.2s ease-in-out 0s;
-ms-transition: all 0.2s ease-in-out 0s;
transition: all 0.2s ease-in-out 0s;
}
#ini {
color:#fff;
background: #7AAFD1;
}
.navigatorSecond li a:hover, .navigatorSecond li:hover > a {
color:#fff;
background: #7AAFD1;
}
.navigatorSecond ul {
display: none;
margin: 0;
padding: 0;
width: 170px;
position: absolute;
left: 0px;
}
.navigatorSecond ul li {
display:block;
float: none;
background:none;
margin:0;
padding:0;
}
.navigatorSecond ul li a {
font-size:13px;
font-weight:bold;
display:block;
color:#797979;
border-left: 3px solid #ffffff;
background: #fff;
line-height: 42px;
transition: 0s;
}
<div class="menuWrap">
<ul class="navigator">
<li>HOME</li>
<li>CHAMPIONS</li>
<li>SOLO QUEUE <img class="iconMenu" src="/icon/expandir.png" alt=""/>
<ul class="sub-menu">
<li>Tier List</li>
<li>Basics & Tactics</li>
<li>Psychology</li>
<li>Picks & Bans</li>
<li>Division analysis</li>
</ul>
</li>
<li>PRO SCENE <img class="iconMenu" src="/icon/expandir.png" alt=""/>
<ul class="sub-menu">
<li>Sub-Menu 1</li>
<li>Sub-Menu 2</li>
<li>Sub-Menu 3</li>
</ul>
</li>
<li>IN-DEPTH ANALYSIS</li>
<li>STATISTICS</li>
</ul>
</div>
I think it is because the font is a bit bolder in Chrome and that causes the button width to be higher.
Thanks in advance
Update: This is because each browser has its own font rendering engine.
I replicated your results with your current sans-serif font. The case also occurred when I changed the font to monospace.
I believe you're better off using a non-system font. For instance, I wanted to see what would happen with a typical Google font such as Open Sans, and I found that the issue did not exist when using it.
By the way, good work on that website. It looks nice. TSM! TSM! TSM!
*{margin:0; padding:0;}
put this line in top of your css file. It helps me for different browser. Just let me know that it helps you or not.
.navigatorSecond li {
display: inline-block;
position: relative;
z-index:80;
}
instead of display inline-block use float left. that will not be different. or use .navigatorsecond{font-size=0;}

css menu hover text color

I have this menu snipped and I am interested to know if there is any possibility to edit the CSS code, in order to obtain in the end a menu text in 2 colors (initial and on mouse over) on transparent background, applying the css text transition from one color to another.
body {
font: normal 1.0em Arial, sans-serif;
background: #A8CBFF;
}
nav {
font-size: 3.0em;
line-height: 1.0em;
color: white;
width:6em;
height: 9.0em;
position:absolute;
top:0; bottom:0;
margin:auto;
left: -4.5em;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
}
nav ul li {
background-color: blue;
height: 1.0em;
padding: 0.25em;
position: relative;
border-top-right-radius: 0.75em;
border-bottom-right-radius: 0.75em;
-webkit-transition: -webkit-transform 500ms, background-color 500ms, color 500ms;
transition: transform 500ms, background-color 500ms, color 500ms;
}
nav ul li:nth-child(1) { background-color: #00aced;}
nav ul li:nth-child(2) { background-color: #3b5998;}
nav ul li:nth-child(3) { background-color: #517fa4;}
nav ul li:nth-child(4) { background-color: #007bb6;}
nav ul li:nth-child(5) { background-color: #cb2027;}
nav ul li:nth-child(6) { background-color: #ea4c89;}
nav ul li:hover {
background-color: #C1232D;
-webkit-transform: translateX(4.5em);
transform: translateX(4.5em);
}
nav ul li span {
display:block;
font-family: Arial;
position: absolute;
font-size:1em;
line-height: 1.25em;
height:1.0em;
top:0; bottom:0;
margin:auto;
right: 0.16666666666667em;
color: #F8F6FF;
}
a {
color: #FFF;
text-decoration: none;
}
<nav>
<ul>
<li>Category 1</li>
<li>Category 2</li>
<li>Category 3</li>
<li>Category 4</li>
<li>Category 5</li>
<li>Category 6</li>
</ul>
</nav>
I've figured it out by setting background-color: to transparent; CodePen here; but at this point, I'm not so sure how to deal with the text colors because if I change a {color: red;} for example, I'll obtain a static color even on mouse over event, not a crossfading visual effect from one text color to another.
Putting it in the transition works. You just need to add a transition property to a selector that selects the a, not just the li. Specifically, nav ul li:hover a { color: black; }:
body {
font: normal 1.0em Arial, sans-serif;
background: #A8CBFF;
}
nav {
font-size: 3.0em;
line-height: 1.0em;
color: white;
width:6em;
height: 9.0em;
position:absolute;
top:0;
bottom:0;
margin:auto;
left: -4.5em;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
}
nav ul li {
background-color: blue;
height: 1.0em;
padding: 0.25em;
position: relative;
border-top-right-radius: 0.75em;
border-bottom-right-radius: 0.75em;
-webkit-transition: -webkit-transform 500ms, background-color 500ms, color 500ms;
transition: transform 500ms, background-color 500ms, color 500ms;
}
nav ul li:nth-child(1) {
background-color: #00aced;
}
nav ul li:nth-child(2) {
background-color: #3b5998;
}
nav ul li:nth-child(3) {
background-color: #517fa4;
}
nav ul li:nth-child(4) {
background-color: #007bb6;
}
nav ul li:nth-child(5) {
background-color: #cb2027;
}
nav ul li:nth-child(6) {
background-color: #ea4c89;
}
nav ul li:hover {
background-color: #C1232D;
-webkit-transform: translateX(4.5em);
transform: translateX(4.5em);
}
nav ul li:hover a {
transition: color, 1500ms;
color: black;
}
nav ul li span {
display:block;
font-family: Arial;
position: absolute;
font-size:1em;
line-height: 1.25em;
height:1.0em;
top:0;
bottom:0;
margin:auto;
right: 0.16666666666667em;
color: #F8F6FF;
}
a {
color: #FFF;
text-decoration: none;
}
<nav>
<ul>
<li>Category 1</li>
<li>Category 2</li>
<li>Category 3</li>
<li>Category 4</li>
<li>Category 5</li>
<li>Category 6</li>
</ul>
</nav>
You can change the text color to whatever you want, of course.

dropdown menu without borders

I want to do one small and easy dropdown menu, but I dont get it how to do this.
What I exacly mean ? :
And I want to do this thisway: If u click on ENG then its going to index_eng.html, but its not working.
My html:
<nav id="menu2">
<select>
<option href="index.html" value="est">EST</option>
<option href="index_eng.html" value="eng">ENG</option>
</select>
</nav>
My css:
#menu2 {
height: 30px;
overflow: visible;
border-radius: 5px;
background-color: #484848;
color: #FFFFFF;
padding: 5px 5px 0px 5px;
margin: 5px 5px 5px 5px;
font: 8pt verdana, arial, sans-serif;
}
At the moment I have this menu like this, but I want it like this picture above.
Need some clue or solution. Thank you!
Why don't you use anchors?
<nav id="menu2">
<ul>
<li>EST</li>
<li>ENG</li>
</ul>
</nav>
If you do not want to use anchors, you can achieve navigation with jQuery:
$('option').click(function() {
var url = $(this).attr('href');
window.location = url;
});
Try this if the above does not work:
window.location.assign(url);
This is very simple CSS3 drop-down menu:
Demo: http://jsfiddle.net/ahqbbwbm/11/
HTML
<ul>
<li>
EST <span class="arrow-down"></span>
<ul>
<li>EST</li>
<li>ENG</li>
</ul>
</li>
</ul>
CSS
ul {
text-align: left;
display: inline;
margin: 0;
padding: 15px 4px 17px 0;
list-style: none;
}
ul li {
font: bold 12px/18px sans-serif;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 15px 20px;
background: #2980b9;
cursor: pointer;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
color: #fff;
}
ul li:hover {
background: #555;
color: #fff;
}
ul li ul {
padding: 0;
position: absolute;
top: 48px;
left: 0;
width: 150px;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
display: none;
opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.2s;
-moz-transition: opacity 0.2s;
-ms-transition: opacity 0.2s;
-o-transition: opacity 0.2s;
-transition: opacity 0.2s;
}
ul li ul li {
min-width: 80px;
background-color: #555;
}
ul li ul li > a {
text-decoration: none;
display: block;
color: #fff;
}
ul li ul li:hover {
background: #666;
}
ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
ul li > span {
display: inline-block;
margin: 0 0 -3px 5px;
width: 12px;
height: 12px;
background-image: url('https://cdn2.iconfinder.com/data/icons/ios-7-icons/50/down4-24.png'); /* Change this */
background-size: 12px 12px;
}
http://jsfiddle.net/yf18w6ay/
css
select{
border:0px;
outline:0px;
}
Below is the example for simple pure CSS Drop Down Menu..
HTML
<nav id="primary">
<ul>
<li>Menu 1
<ul>
<li>Sub Menu 1</li>
<li>Sub Menu 2</li>
<li>Sub Menu 3</li>
<li>Sub Menu 4
<ul>
<li>Deep Menu 1
</li>
<li>Deep Menu 2</li>
</ul>
</li>
<li>Sub Menu 5</li>
</ul>
</li>
</ul>
CSS
#primary
{
margin-top:15px
}
#primary ul
{
list-style:none;
position:relative;
float:left;
margin:0;
padding:0
}
#primary ul a
{
display:block;
color:#333;
text-decoration:none;
font-weight:700;
font-size:12px;
line-height:32px;
padding:0 15px;
font-family:"HelveticaNeue","Helvetica Neue",Helvetica,Arial,sans-serif
}
#primary ul li
{
position:relative;
float:left;
margin:0;
padding:0
}
#primary ul li.current-menu-item
{
background:#ddd
}
#primary ul li:hover
{
background:#f6f6f6
}
#primary ul ul
{
display:none;
position:absolute;
top:100%;
left:0;
background:#fff;
padding:0
}
#primary ul ul li
{
float:none;
width:200px
}
#primary ul ul a
{
line-height:120%;
padding:10px 15px
}
#primary ul ul ul
{
top:0;
left:100%
}
#primary ul li:hover > ul
{
display:block
}

Auto width for submenu

I can't get this to work, but in my dropdown menu I just simply can't find a way to make the dropdown menu (for example on account) have it scale with the text.
I tried many things, but only so far a static width is working but that is not what I want
<div class="menu-wrap">
<div class="menu">
<ul class="menu-inner">
<li class="home">Home</li>
<li class="account">Mijn Account
<ul>
<li>Mijn website</li>
<li>Profiel</li>
<li>Persoonlijke gegevens</li>
<li>Voorkeuren</li>
<li>Email instellingen</li>
<li>Log uit</li>
</ul>
</li>
<li class="pages">Mijn pagina's
<ul>
<li>Mijn pagina's</li>
<li>Maak een nieuwe pagina</li>
<li>Verander pagina volgorde</li>
</ul>
</li>
<li class="messages">Mijn berichten
<ul>
<li>Alle privè berichten</li>
<li>Verzonden berichten</li>
<li>Verwijderde berichten</li>
<li>Ongelezen berichten</li>
</ul>
</li>
<li class="forum">Forum
<ul>
<li>Nieuwste berichten</li>
<li>Overzicht</li>
<li>Mijn berichten</li>
<li>Top posters</li>
<li>Zoek topic</li>
</ul>
</li>
<li class="search">Zoeken
<ul>
<li>Zoeken</li>
<li>Vandaag jarig</li>
<li>Online leden</li>
<li>Alle leden</li>
<li>Zoek topic</li>
</ul>
</li>
<li class="online">Online (x)
</ul>
</div>
</div>
and the css code:
.menu-wrap{
position: relative;
background-color: rgba(0,0,0,0.8);
height: 30px;
width: 100%;
text-align: center;
}
.menu {
position: relative;
width: 860px;
margin: 0px auto;
height: 30px;
line-height: 30px;
}
.menu ul {
text-align: left;
display: inline;
margin: 0;
padding: 0;
list-style: none;
}
.menu ul li {
font: bold 12px/18px sans-serif;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 5px 22px;
cursor: pointer;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
}
.menu ul li:hover {
background-color: rgba(0,0,0,0.4);
}
.menu ul li a {
color: #fff;
text-decoration: none;
font-size: 14px;
}
.menu ul li ul {
padding: 0;
position: absolute;
top: 28px;
left: 0;
width: auto;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
display: none;
opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.2s;
-moz-transition: opacity 0.2s;
-ms-transition: opacity 0.2s;
-o-transition: opacity 0.2s;
-transition: opacity 0.2s;
background-color: rgba(0,0,0,0.4)
}
.menu ul li ul li {
color: #fff;
}
.menu ul li ul li:hover { background-color: rgba(0,0,0,0.4);}
.menu ul li:hover ul {
display:inline-block;
opacity: 1;
visibility: visible;
}
All I want is have the sub menus auto scale in width with the text!
You are going to have to add a white-space property to the .menu ul li ul li rule like so:
.menu ul li ul li {
white-space: nowrap;
}

How to add space between menu and dropdown submenu

I'm working on a CSS3 full width dropdown menu, but some details i can't get right. :-(
What i try to achieve is this:
You can see there is a little 20px space between the mainmenu and the submenu. In this example i used a top-margin:20px for the ul submenu. But that doesn't really work, because you will leave the hover-area with your cursor and the submenu wil dissapear. The dropdown only works if the ul-container of the submenu "touches" the hover-area.
It did tried using the ul:before trick to add an empty block before the submenu ul, but somehow that doesn't work. :( It doens't take space like a block should do. It's just adding the content right over the ul element.
What do i overlook or doing wrong here? :( Why is the ul ul:after not working? Is there a better way to add a little bit of empty "hoverspace" above the submenu?
Your help would be very helpfull :-).
Live demo:
http://jsfiddle.net/JeroenGerth/hDmxd/
The HTML:
<nav>
<ul id="menu">
<li>Home</li>
<li>Tutorials >
<ul class="submenu">
<li>Photoshop 1</li>
<li>Dreamweaver 2</li>
<li>Photoshop 3</li>
<li>InDesign 4</li>
<li>Bridge 5</li>
<li>Lightroom 6</li>
<li>After Effects 7</li>
<li>Premiere 8</li>
<li>Motion 9</li>
<li>Aperture 10</li>
<li>iPhoto 11</li>
</ul>
</li>
<li>Downloads >
<ul class="submenu">
<li>Wallpapers 1</li>
<li>PSD files 2</li>
<li>Video's 3</li>
<li>Soundeffects 4</li>
<li>Icons 5</li>
<li>Maps 6</li>
</ul>
</li>
<li>About me</li>
<li>Contact</li>
</ul>
</nav>
The CSS:
body {background-color: #E9E9E9;}
nav ul { /*Main menu container*/
margin: 0px;
padding: 0px 20px;
background-color:#444;
color: #fff;
list-style: none;
position:relative;
display:inline-table;
border-radius: 5px;
}
nav ul:after {
content: ""; clear: both; display: block;
}
nav ul li { /*Main menu-items*/ float:left;}
nav ul li a {
padding: 10px 20px;
color: #fff;
font-family: Calibri, Verdana, sans-serif;
text-decoration:none;
display: block;
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
nav ul li a:hover {color: #66D1D3;}
nav ul ul { /*Submenu container*/
display:block;
border-radius:0px;
padding: 0px;
position: absolute;
background-color:#fff;
color: #000;
visibility:hidden;
opacity:0;
transition:all ease-in-out 0.4s;
left: 0px;
top: 100%;
width: 100%;
columns:100px 3;
-webkit-columns:100px 3; /* Safari and Chrome */
-moz-columns:100px 3; /* Firefox */
}
nav ul li:hover > ul { /*Show submenu*/
visibility:visible;
opacity:1;
transition-delay:0s;
}
nav ul ul:before { /*Why doesn't this work :( */
content: "";
display: block;
height: 20px;
position: absolute;
width: 100%;}
nav ul ul li { /*Submenu items*/
float: none;
border-bottom: 1px #CCCCCC dotted;
position:relative;
}
nav ul ul li a {
color: #000;
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
nav ul ul li a:hover {
color: #66D1D3;
background-color: #444;
}
Add a margin-top to nav ul li:hover > ul:
nav ul li:hover > ul {
visibility:visible;
opacity:1;
transition-delay:0s;
margin-top: 20px; /* new */
}
Updated fiddle: http://jsfiddle.net/hDmxd/3/
Note: it won't disappear since the easing fadeout gives enough time for the user's mouse to leave the menu and enter the sub-menu.
nav ul li:hover > ul {
visibility:visible;
opacity:1;
transition-delay:0s;
margin-top:1.3em; /* added new */
}
You haven't submitted you styles on the class "nav" or it's parent! The space can be adjusted by playing about with the padding. e.g.
nav {
padding: 10px 5px 10px 5px;
}
div { //that's the div above your nav
padding: 10px 5px 10px 5px;
}
It's either one or the other