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
}
Related
The Problem:
Look at Offers and the li:
After putting position: absolute
Current vs What I want to achieve
How to make my drop down menu so that when I hover on "Offers" the text doesn't move to the left? I would also like to decrease the width of the li as it is too big for me.
I have tried changing the display: property and putting spaces before and after the word "Offers" in HTML. The spaces worked but I didnt like it because the Offers will just look like having more space than the other options.
.nav {
position: fixed;
top: 0;
left: 0;
margin: 0;
padding: 0;
width: 100%;
height: 80px;
}
.menu {
float: right;
line-height: 80px;
margin: 0 9em;
text-align: center;
font-family: "Proxima Nova";
text-transform: uppercase;
font-weight: bolder;
letter-spacing: 0px;
}
.menu ul {
margin: 0px;
padding: 0px;
list-style: none;
}
.menu ul li {
text-align: center;
list-style: none;
display: inline-table;
}
.menu ul li a {
text-decoration: none;
color: white;
font-size: 16px;
font-weight: lighter;
padding: 0 20px;
transition: all .3s ease-in-out;
}
.menu ul li a:hover {
color: orange;
}
.menu ul li ul li {
display: none; /*So li dont show up unless hover */
}
.menu ul li:hover ul li {
transition: all .3s ease;
display: block;
background: rgba(0, 0, 0, .6);
}
ul li:nth-child(5) a {
color: white;
border: 1px solid orange;
padding: 10px 20px;
border-radius: 4px;
background-color: none;
transition: all 1s ease-out;
}
ul li:nth-child(5) a:hover {
transition: all .5s ease-in;
background: rgba(204, 204, 204, 0.5);
color: orange;
}
<div class="nav">
<div class="menu">
<ul>
<li>Home</li>
<li>About Us</li>
<li>Offers
<ul>
<li>Packages</li>
<li>Services</li>
<li>Promos</li>
</ul>
</li>
<li>Location</li>
<li>Contact</li>
</ul>
</div>
</div>
I want to dropdown menu to not move when the li is shown in the Offers. And I would like to decrease the width of black background of the li
That's because the sub menu is taking a place and make its parent li wider.
A possible solution is to set the ul child position: absolute so it will not take a place.
Like this:
.menu ul ul {
position: absolute;
}
Live example:
body {
background: url(https://cdn.pixabay.com/photo/2017/08/30/01/05/milky-way-2695569_960_720.jpg) 0 0;
background-size: cover;
}
.nav {
position: fixed;
top: 0;
left: 0;
margin: 0;
padding: 0;
width: 100%;
height: 80px;
}
.menu {
float: right;
line-height: 80px;
margin: 0 9em;
text-align: center;
font-family: "Proxima Nova";
text-transform: uppercase;
font-weight: bolder;
letter-spacing: 0px;
}
.menu ul {
margin: 0px;
padding: 0px;
list-style: none;
}
.menu ul li {
text-align: center;
list-style: none;
display: inline-table;
position: relative;
}
.menu ul li a {
text-decoration: none;
color: white;
font-size: 16px;
font-weight: lighter;
padding: 0 20px;
transition: all .3s ease-in-out;
}
.menu ul li a:hover {
color: orange;
}
.menu ul ul {
position: absolute;
width: 100%;
}
.menu ul li ul li {
display: none;
/*So li dont show up unless hover */
}
.menu ul li ul li a {
padding: 0;
text-align: center;
}
.menu ul li:hover ul li {
transition: all .3s ease;
display: block;
background: rgba(0, 0, 0, .6);
}
ul li:nth-child(5) a {
color: white;
border: 1px solid orange;
padding: 10px 20px;
border-radius: 4px;
background-color: none;
transition: all 1s ease-out;
}
ul li:nth-child(5) a:hover {
transition: all .5s ease-in;
background: rgba(204, 204, 204, 0.5);
color: orange;
}
<div class="nav">
<div class="menu">
<ul>
<li>Home</li>
<li>About Us</li>
<li>Offers
<ul>
<li>Packages</li>
<li>Services</li>
<li>Promos</li>
</ul>
</li>
<li>Location</li>
<li>Contact</li>
</ul>
</div>
</div>
The problem lies with the min-content size of the list items in the drop down, which are larger than the size of the parent list items in the top menu.
e.g. 'packages' renders at 120px whereas 'offers' is 98px.
The simplest solution is to set a max-width for all the list items based on the max-content size of the longest word (not very dynamic though).
Otherwise, use position:absolute to layout the sub menu as in this example:
https://codepen.io/skippingredpanda/pen/xNrxVg
Is simple, use:
.menu li { position: relative; } .menu li ul { position: absolute; top: your horizontal nav height; left: 0;}
And also you have a mistake in code, must be like this:
<ul>
<li>Link 1</li>
<li>Link 2</li>
<li>
Link 3
<ul>
<li>SubLink 1</li>
<li>SubLink 2</li>
<li>SubLink 3</li>
<li>SubLink 4</li>
</ul>
</li>
<li>Link 4</li>
</ul>
ul li {position: relative;}
ul li ul {position: absolute; display: none;}
ul li:hover ul {display: block;}
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.
I want to add a delay on mouse out from hover menu. Here is my codepen: http://codepen.io/anon/pen/MYjzVb
Please notice that I have used these lines for CSS transitions:
-webkit-transition: visibility 0.65s ease-in;
-moz-transition: visibility 0.65s ease-in;
But this doesn't works. I am using Chrome browser, tried to view it in Firefox too but that doesn't helps.
Please help!
1- WITHOUT ANIMATION:
/**RESETING BROWSER STYLE*/
*{box-sizing: border-box; padding: 0; margin: 0}
/**SETTING THE ROOT ELEMENT BACKGROUND*/
:root{background: #ccc}
/**REMOVING THE STYLE ON ALL LIST IN [id=panel]*/
[id=panel] li{
list-style-type: none
}
/**INIT OUR DROP MENU*/
.drop_menu {
background: #10BDF5;
height: 25px
}
/* SUBMENU position:absolute AND OPACITY INSTEAD OF VISIBILITY and ease-out not ease-in*/
.drop_menu ul {
position: absolute;
left: 0;
top: 28px;
height: 0; /**SET THIS TO ZERO SINCE WE CAN'T ANIMATE display: none*/
overflow: hidden; /**YOU NEED THIS TO HIDE THE LIST*/
background:#51C7ED;
border-bottom: 5px solid transparent;
border-bottom-right-radius: 3px;
border-bottom-left-radius: 3px;
opacity: 0; /**DO NOT DISPLAY THE LIST ON INIT STATE*/
transition:opacity 0 5s linear, height 0 5s linear,border-bottom 0 5s linear/**TRANSITION ON OPACITY WITHOUT DELAY BUT ON HEIGHT WITH A DELAY GREATER OR EGAL THE OPACITY ANIMATION DURATION*/
}
.drop_menu li:hover ul {
transition:height 0s ease-out ;/**TRANSITION ONLY ON HEIGHT*/
opacity: 1;
border-bottom: 5px solid #1292BB;
height: 76px /**SET THE HEIGHT ON MOUVE IN*/
}
/**GIVING position: relative TO THE PARENT OF OUR UNORDERED LIST SINCE IT HAS position:absolute */
.drop_menu li { float:left; position: relative}
.drop_menu li a {
padding:3px 6px;
display:block;
color:#FFF;
text-decoration:none;
font-size: 11px;
line-height: 22px;
}
.drop_menu li:hover { position:relative; background:#51C7ED; }
.drop_menu ul a {
padding:1px 4px;
display:block;
width:150px;
font-size: 11px;
text-indent:11px;
background-color:#10BDF5;
}
.drop_menu li:hover ul li a {
padding:1px 4px;
display:block;
width:150px;
font-size: 11px;
text-indent:11px;
background-color:#10BDF5;
}
.drop_menu li:hover ul li a:hover { background:#51C7ED }
#panel {
background: #10BDF5;
color: #FFF;
font-size: 11px;
text-align: left;
border: 1px solid #30B3DE;
padding: 3px 4px
}
<div id="panel">
<ul class="drop_menu">
<li>Upgrade Account</li>
<li>Link One
<ul>
<li>link</li>
<li>link</li>
<li>link</li>
</ul>
</li>
<li>Link Two</li>
</ul>
</div>
2- WITH ANIMATION
/**RESETING BROWSER STYLE*/
*{box-sizing: border-box; padding: 0; margin: 0}
/**SETTING THE ROOT ELEMENT BACKGROUND*/
:root{background: #ccc}
/**REMOVING THE STYLE ON ALL LIST IN [id=panel]*/
[id=panel] li{
list-style-type: none
}
/**INIT OUR DROP MENU*/
.drop_menu {
background: #10BDF5;
height: 25px
}
/* SUBMENU position:absolute AND OPACITY INSTEAD OF VISIBILITY and ease-out not ease-in*/
.drop_menu ul {
position: absolute;
left: 0;
top: 28px;
height: 0; /**SET THIS TO ZERO SINCE WE CAN'T ANIMATE display: none*/
overflow: hidden; /**YOU NEED THIS TO HIDE THE LIST*/
background:#51C7ED;
border-bottom: 5px solid transparent;
border-bottom-right-radius: 3px;
border-bottom-left-radius: 3px;
opacity: 0; /**DO NOT DISPLAY THE LIST ON INIT STATE*/
transition:opacity 0.65s ease-out, height 0 0.68s linear /**TRANSITION ON OPACITY WITHOUT DELAY BUT ON HEIGHT WITH A DELAY GREATER OR EGAL THE OPACITY ANIMATION DURATION*/
}
.drop_menu li:hover ul {
transition:height 0s ease-out ;/**TRANSITION ONLY ON HEIGHT*/
opacity: 1;
border-bottom: 5px solid #1292BB;
height: 76px /**SET THE HEIGHT ON MOUVE IN*/
}
/**GIVING position: relative TO THE PARENT OF OUR UNORDERED LIST SINCE IT HAS position:absolute */
.drop_menu li { float:left; position: relative}
.drop_menu li a {
padding:3px 6px;
display:block;
color:#FFF;
text-decoration:none;
font-size: 11px;
line-height: 22px;
}
.drop_menu li:hover { position:relative; background:#51C7ED; }
.drop_menu ul a {
padding:1px 4px;
display:block;
width:150px;
font-size: 11px;
text-indent:11px;
background-color:#10BDF5;
}
.drop_menu li:hover ul li a {
padding:1px 4px;
display:block;
width:150px;
font-size: 11px;
text-indent:11px;
background-color:#10BDF5;
}
.drop_menu li:hover ul li a:hover { background:#51C7ED }
#panel {
background: #10BDF5;
color: #FFF;
font-size: 11px;
text-align: left;
border: 1px solid #30B3DE;
padding: 3px 4px
}
<div id="panel">
<ul class="drop_menu">
<li>Upgrade Account</li>
<li>Link One
<ul>
<li>link</li>
<li>link</li>
<li>link</li>
</ul>
</li>
<li>Link Two</li>
</ul>
</div>
You could use JavaScript for handling mouseenter and mouseleave events and use setTimeout() for the delay(5s) on mouseleave event.
You could set the delay through the variable delay.
Updated CodePen
var items = document.querySelectorAll('.drop_menu > li');
var delay = 5000;
for (i = 0; i < items.length; i++) {
items[i].addEventListener('mouseenter', function() {
var c = this.children
for (j = 0; j < c.length; j++) {
if (c[j].localName == 'ul') {
c[j].style.display = 'block';
c[j].style.position = 'absolute';
}
}
});
items[i].addEventListener('mouseleave', function() {
mouseLeave(this, j);
});
}
function mouseLeave(el, j) {
setTimeout(function() {
var c = el.children;
for (j = 0; j < c.length; j++) {
if (c[j].localName == 'ul') {
c[j].style.display = 'none';
}
}
}, delay)
}
.drop_menu {
background: #10BDF5;
padding: 0;
margin: 0;
list-style-type: none;
height: 25px;
}
.drop_menu li {
display: inline-block;
}
.drop_menu li a {
padding: 3px 6px;
display: block;
color: #FFF;
text-decoration: none;
font-size: 11px;
line-height: 22px;
}
/* Submenu */
.drop_menu ul {
position: absolute;
display: none;
list-style-type: none;
}
.drop_menu > li {
position: relative;
}
.drop_menu li:hover {
background: #51C7ED;
}
.drop_menu li ul {
left: 0px;
top: 28px;
background: #51C7ED;
padding: 0px;
border-bottom: 5px solid #1292BB;
border-bottom-right-radius: 3px;
border-bottom-left-radius: 3px;
}
.drop_menu li ul li a {
padding: 1px 4px;
display: block;
width: 150px;
font-size: 11px;
text-indent: 11px;
background-color: #10BDF5;
}
.drop_menu li:hover ul li a:hover {
background: #51C7ED;
}
#panel {
background: #10BDF5;
color: #FFF;
font-size: 11px;
text-align: left;
border: 1px solid #30B3DE;
padding: 3px 4px;
}
<div id="panel">
<ul class="drop_menu">
<li>Upgrade Account
</li>
<li>Link One
<ul>
<li>link
</li>
<li>link
</li>
<li>link
</li>
</ul>
</li>
<li>Link Two
</li>
</ul>
</div>
When I hover over my first navigation link the sublists don't line up vertically underneath each other but are beside each other instead. How do I get them to be the same width as the top navigation display vertically when hovered over?
My HTML:
<nav>
<ul>
<li>
fashion
<ul>
<li>street style</li>
<li>celebrity style</li>
</ul>
</li>
<li>beauty</li>
<li>music</li>
<li>entertainment</li>
</ul>
</nav>
My CSS:
nav {
font-family: 'Josefin Sans', sans-serif;
}
nav li {
display:block;
width: 25%;
background-color: #000;
position:relative;
float:left;
list-style:none;
}
nav a {
text-decoration: none;
font-size: 17px;
color: white;
padding:6pt 0;
text-align: center;
display: block;
border-bottom: 3px white solid;
text-transform:uppercase;
}
nav a:hover{
background: #d04576;
border-bottom: 3px white solid;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
-ms-transition: all 0.5s;
-o-transition: all 0.5s;
transition: all 0.5s;
}
nav ul li ul {
display:none;
width:100%;
}
nav li:hover ul {
display: block;
width:100%;
}
You are floating all of your li left.
Setting your nav li li to float: none; should do the trick. Try adding this to your css:
nav li li{
float: none;
}
Edit: Here is a jsFiddle: http://jsfiddle.net/TscH5/3/
I added comments at the top to explain the few things I fixed.
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