Can someone please help me do dropdown transition here... ?
On hover the dropdown should show up in fade-in manner. This is really confusing because right transition is not working no matter where I apply it. This colorful menu is just an example to get the right idea on how to make the dropdown transition work. I just need a simple ease-in transition that will work. I have been trying hard to fix this. Help is greatly appreciated.
<ul id='nav'>
<li class='menuitem1'>mainmenu1
<ul>
<li class='menuitem1'>Menu 111</li>
<li class='menuitem1'>Menu 22</li>
<li class='menuitem1'>Menu 3333</li>
<li class='menuitem1'>Menu 44
</li>
</ul>
</li>
<li class='menuitem2'>Menu3774
<ul>
<li class='menuitem2'>Menu 111</li>
<li class='menuitem2'>Menu 22</li>
<li class='menuitem2'>Menu 3333</li>
<li class='menuitem2'>Menu 44
</li>
</ul>
</li>
<li class='menuitem3'>Menury
</li>
</ul>
</nav>
<style>
.menuitem1 {
background:#4dd2ff;
}
.menuitem1:hover {
color:#000;
background:#94e4ff;
}
.menuitem2 {
background:#1aff8c;
}
.menuitem2:hover {
background:#87ffc3;
}
.menuitem3 {
background:#d2a679;
}
.menuitem3:hover {
background:#f5c89a;
}
nav > ul {
transition-duration: 0.5s;
}
#nav {
display:table;
margin:0;
}
#nav > li {
cursor:pointer;
list-style:none;
padding:12px 0;
border:1px #959696 solid;
position:relative;
display:table-cell;
width:1%;
text-align:center;
}
#nav ul li {
width: 250px;
display:block;
padding:3px 20px;
text-indent:0;
line-height:40px;
text-align:left;
border-top:1px #fff solid;
border-bottom:1px #fff solid;
border-left:none;
border-right:none;
position:relative;
}
#nav ul {
visibility:hidden;
opacity:0;
max-height:300px;
position:absolute;
filter:alpha(opacity=0);
transition: height 0.3s ease-in;
}
#nav li:hover > ul {
visibility:visible;
opacity:1;
filter:alpha(opacity=100);
}
ul {
display:none;
}
li:hover > ul {
display:block;
position:absolute;
z-index:1000;
border:1px #fff solid;
margin-top:12px;
margin-left:0;
}
#nav > li ul li ul {
left:100%;
top:-2px;
white-space:nowrap;
}
#nav li:hover > a, #nav li:hover {
}
li, li a {
color:#000;
text-decoration:none;
}
* {box-sizing:border-box;-moz-box-sizing:border-box;}
</style>
The transition becomes broken by the conflicting #nav styles you have for the menu. Creating class names is generally a recommended practice. I would reference the following example written on CodePen: https://codepen.io/shshaw/pen/gsFch
<nav>
<ul>
<li class="sub-menu-parent" tab-index="0">
Menu Item 1
<ul class="sub-menu">
<li>Sub Item 1</li>
<li>Sub Item 2</li>
<li>Sub Item 3</li>
<li>Sub Item 4</li>
</ul>
</li>
<li class="sub-menu-parent" tab-index="0">
Menu Item 2
<ul class="sub-menu">
<li>Sub Item 1</li>
<li>Sub Item 2</li>
<li>Sub Item 3</li>
<li>Sub Item 4</li>
<li>Sub Item 5</li>
<li>Sub Item 6</li>
</ul>
</li>
<li class="sub-menu-parent" tab-index="0">
Menu Item 3
<ul class="sub-menu">
<li>Sub Item 1</li>
<li>Sub Item 2</li>
</ul></li>
</ul>
</nav>
<style>
.sub-menu-parent { position: relative; }
.sub-menu {
visibility: hidden; /* hides sub-menu */
opacity: 0;
position: absolute;
top: 100%;
left: 0;
width: 100%;
transform: translateY(-2em);
z-index: -1;
transition: all 0.3s ease-in-out 0s, visibility 0s linear 0.3s, z-index 0s linear 0.01s;
}
.sub-menu-parent:focus .sub-menu,
.sub-menu-parent:focus-within .sub-menu,
.sub-menu-parent:hover .sub-menu {
visibility: visible; /* shows sub-menu */
opacity: 1;
z-index: 1;
transform: translateY(0%);
transition-delay: 0s, 0s, 0.3s; /* this removes the transition delay so the menu will be visible while the other styles transition */
}
/* presentational */
body { padding: 2%; font: 18px/1.4 sans-serif; }
nav a { color: #E00; display: block; padding: 0.5em 1em; text-decoration: none; }
nav a:hover { color: #F55; }
nav ul,
nav ul li { list-style-type: none; padding: 0; margin: 0; }
nav > ul { background: #EEE; text-align: center; }
nav > ul > li { display: inline-block; border-left: solid 1px #aaa; }
nav > ul > li:first-child { border-left: none; }
.sub-menu {
background: #DDD;
}
</style>
The action you want to do is css animation. Animation duration "animation-duration: 4s;" You can adjust it according to you. You can edit the transitions you want to do with "#keyframes example". For more information you can check here. https://www.w3schools.com/css/css3_animations.asp
.menuitem1 {
background:#4dd2ff;
}
.menuitem1:hover {
color:#000;
background:#94e4ff;
}
.menuitem2 {
background:#1aff8c;
}
.menuitem2:hover {
background:#87ffc3;
}
.menuitem3 {
background:#d2a679;
}
.menuitem3:hover {
background:#f5c89a;
}
nav > ul {
transition-duration: 0.5s;
}
#nav {
display:table;
margin:0;
}
#nav > li {
cursor:pointer;
list-style:none;
padding:12px 0;
border:1px #959696 solid;
position:relative;
display:table-cell;
width:1%;
text-align:center;
}
#nav ul li {
animation-name: example;
animation-duration: 4s;
width: 250px;
display:block;
padding:3px 20px;
text-indent:0;
line-height:40px;
text-align:left;
border-top:1px #fff solid;
border-bottom:1px #fff solid;
border-left:none;
border-right:none;
position:relative;
}
#keyframes example {
from {background-color: #94e4ff00;}
to {background-color: #94e4ff;}
from {color: #94e4ff00;}
to {color: black;}
}
#nav ul {
visibility:hidden;
opacity:0;
max-height:300px;
position:absolute;
filter:alpha(opacity=0);
transition: height 0.3s ease-in;
}
#nav li:hover > ul {
visibility:visible;
opacity:1;
filter:alpha(opacity=100);
}
ul {
display:none;
}
li:hover > ul {
display:block;
position:absolute;
z-index:1000;
border:1px #fff solid;
margin-top:12px;
margin-left:0;
}
#nav > li ul li ul {
left:100%;
top:-2px;
white-space:nowrap;
}
#nav li:hover > a, #nav li:hover {
}
li, li a {
color:#000;
text-decoration:none;
}
* {box-sizing:border-box;-moz-box-sizing:border-box;}
<ul id='nav'>
<li class='menuitem1'>mainmenu1
<ul>
<li class='menuitem1'>Menu 111</li>
<li class='menuitem1'>Menu 22</li>
<li class='menuitem1'>Menu 3333</li>
<li class='menuitem1'>Menu 44
</li>
</ul>
</li>
<li class='menuitem2'>Menu3774
<ul>
<li class='menuitem2'>Menu 111</li>
<li class='menuitem2'>Menu 22</li>
<li class='menuitem2'>Menu 3333</li>
<li class='menuitem2'>Menu 44
</li>
</ul>
</li>
<li class='menuitem3'>Menury
</li>
</ul>
</nav>
Related
I'm trying to have the sub menu items disappear after a certain amount of time using CSS only. Sadly if I have more than one sub menu and hover over the next sub menu the other one has not yet disappeared. Any way to make the previous sub menu disappear when the next sub menu is show with CSS only?
It wouldn't be hard for me to write a JQuery script to achieve this but would nice if I could do it using css. Would there be any JS/JQuery plugins to recommend if this is not possible with CSS?
http://codepen.io/anon/pen/aBPBbj
nav > ul > li {
display: inline-block
}
nav > ul > li ul {
visibility: hidden;
position: absolute;
top: 105%;
left: 0;
transition: 0.2s 1s;
}
nav > ul > li:hover ul {
visibility: visible;
transition-delay: 0s;
}
nav ul {
list-style: none;
padding: 0;
margin: 0;
}
nav li {
width: 100px;
background: #eee;
margin: 2px;
position: relative;
padding: 10px;
}
nav a {
display: block;
}
body {
padding: 10px;
}
<nav>
<ul>
<li>
Dropdown
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
</li>
<li>
Dropdown
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
</li>
</ul>
</nav>
Try to remove transition: 0.2s 1s;
Just change the tarnsition time as shown below code.
nav > ul > li ul {
visibility: hidden;
position: absolute;
top: 105%;
left: 0;
transition: 0.2s;
}
Try this example of code:
<ul id="mainNav">
<li>item 1
<ul>
<li>sub item 1</li>
<li>sub item 2</li>
<li>sub item 3</li>
</ul>
</li>
<li>item 2
<ul>
<li>sub item 1</li>
<li>sub item 2</li>
<li>sub item 3</li>
<li>sub item 4</li>
</ul>
</li>
<li>item 3
<ul>
<li>sub item 1</li>
<li>sub item 2</li>
</ul>
</li>
ul#mainNav {
float:left;
width:auto;
margin:0; padding:0;
color:white;
list-style-type:none;
}
ul#mainNav > li {
float:left;
display:inline;
position:relative;
padding:5px;
border:1px white solid;
background-color:black;
}
ul#mainNav > li:hover {
background:white;
color:black;
border:1px black solid;
}
ul#mainNav > li:hover ul {
visibility: visible;
opacity: 1;
transition-delay: 0s, 0s;
}
ul#mainNav li ul {
position:absolute;
float:left;
width:100px;
height:0;
padding:10px;
margin:0;
visibility: hidden;
opacity: 0;
transition-property: opacity, visibility;
transition-duration: 1.4s, 0s;
transition-delay: 0s, 0s;
}
ul#mainNav ul li {
background-color:white;
border:1px black solid;
}
ul#mainNav ul li:hover {
background-color:black;
border:1px white solid;
color:white;
visibility: hidden;
opacity: 0;
transition-property: opacity, visibility;
transition-duration: 0s, 0s;
transition-delay: 0s, 0s;
}
Seeing as no one proposed a working CSS only solution apparently the only way to achieve this is through javascript/JQuery.
https://jsfiddle.net/jkanckr3/
<nav>
<ul>
<li>
Dropdown
<ul>
<li>One</li>
<li>Two</li>
<li>Three</a></li>
</ul>
</li>
<li>
Dropdown
<ul>
<li>One</li>
<li>Two</li>
<li>Three</a></li>
</ul>
</li>
</ul>
</nav>
var timeout;
$('nav > ul > li').on({
mouseenter: function () {
clearTimeout(timeout);
$('nav > ul > li > ul').hide();
$('ul', this).show();
},
mouseleave: function () {
var self = this;
timeout = setTimeout(function() {
$('ul', self).hide();
}, 500);
}
});
nav > ul > li {
display: inline-block
}
nav > ul > li ul {
display: none;
position: absolute;
top: 105%;
left: 0;
}
nav > ul > li:hover ul {
//visibility: visible;
}
nav ul {
list-style: none;
padding: 0;
margin: 0;
}
nav li {
width: 100px;
background: #eee;
margin: 2px;
position: relative;
padding: 10px;
}
nav a {
display: block;
}
body {
padding: 10px;
}
I have a menu drop down list which is done using css and html. Now, I want to have an extension of sub menu on the existing sub menu, when I hover the "Audit Report for example, it should show another sub menu vertically. How can I achieve that? This is my existing codes in css and html.
css
.menuPanel
{
width: auto;
height: 32px;
top: 5px;
border-bottom: 1px solid #808080;
background-color: #4f4545;
}
.nav,.nav ul
{
list-style: none;
margin:0;
padding:0;
}
.nav {
position:relative;
left: 2px;
height: auto;
}
.nav ul
{
height:0;
left:0;
overflow: hidden;
position:absolute;
}
.nav li
{
float:left;
position:relative;
}
.nav li a
{
-moz-transition:1.0s;
-o-transition:1.0s;
-webkit-transition:1.0s;
transition:1.0s;
background-color: #4f4545;
display: block;
color:#FFF;
text-decoration:none;
font-size:12px;
line-height:32px;
padding:0px 30px;
}
.nav li:hover > a
{
background: #8CCA33;
border-color: #6E67A6;
color:#fff;
}
.nav li:hover ul.subs
{
height:auto;
width: 250px;
z-index: 10;
}
.nav ul li
{
-moz-transition:0.3s;
-o-transition:0.3s;
-webkit-transition:0.3s;
opacity:0;
transition:0.3s;
width:100%;
}
.nav li:hover ul li
{
opacity:1;
-moz-transition-delay:0.2s;
-o-transition-delay:0.2s;
-webkit-transition-delay:0.2s;
transition-delay:0.2s;
}
.nav ul li a
{
background: #4f4545;
border: 1px solid #808080;
color:#fff;
line-height:1px;
-moz-transition:1.5s;
-o-transition:1.5s;
-webkit-transition:1.5s;
transition:1.5s;
}
.nav li:hover ul li a
{
line-height:32px;
}
.nav ul li a:hover
{
background:#8CCA33;
}
aspx page design
<ul class="nav">
<li>HOME</li>
<li>FILE ▾
<ul class="subs">
<li>Tenants List</li>
<li>Users List</li>
<li>Tenant Rental</li>
</ul>
</li>
<li>REPORTS ▾
<ul class="subs">
<li>Audit Reports
<ul>
<li><a href='#'>Sub Product</a></li>
<li><a href='#'>Sub Product</a></li>
</ul>
</li>
<li>Leasing Reports</li>
<li>Marketing Reports</li>
</ul>
</li>
<li id="admin" visible="true" runat="server">ADMIN ▾
<ul class="subs">
<li>System Logs</li>
<li>User Request</li>
</ul>
</li>
<li>LOG-OUT
</li>
</ul>
</div>
You have to do a new CSS-Style for .nav .subs ul for the whole block or .nav .subs ul li for a single element of the block
example:
.nav .subs li ul
{
max-height: 0;
-moz-transition:1.5s;
-o-transition:1.5s;
-webkit-transition:1.5s;
transition:1.5s;
}
.nav .subs li:hover > ul
{
max-height: 300px;
height: auto;
}
.nav .subs li ul
{
left: 250px;
top: 0;
overflow: hidden;
}
this just shows the new block, if you hover over a submenu-item, now you only have to style it and place it whereever you want it
Example on JSFiddle:
http://jsfiddle.net/4sym7ry0/3/
Do Nested Unorderlist and orderedlist inside your ListItem
Check this For More Info :
http://www.thecodingguys.net/blog/css3-create-a-vertical-menu-with-sub-menu
apologies for basic-ness of question, just creating a dropdown menu and having some problems with the margins and positioning.
Ive set the div of it as 85% but i want that centered in the page,
And then the list items centered in the middle of that so it's all neat but can't get it too.
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li>Home</li>
<li>Second Page</li>
<li>Third Page<span class="arrow">▼</span>
<ul class="sub-menu">
<li>Dropdown One</li>
<li>Dropdown Two</li>
</ul>
</li>
<li>Fourth Page</li>
<li>Fifth Page<span class="arrow">▼</span>
<ul class="sub-menu">
<li>Dropdown 1</li>
<li>Dropdown Item 2</li>
<li>Dropdown 3</li>
<li>Dropdown 4</li>
</ul>
</li>
</ul>
</nav>
CSS:
.clearfix:after {
display:block;
clear:both;
}
.menu-wrap ul {
margin:0px;
padding:0px;
}
.menu-wrap {
width:80%;
background: #85D2CD;
display: inline-block;
margin: auto;
}
.menu {
width:100%;
margin:0px auto;
}
.menu li {
margin:0px;
list-style:none;
}
.menu a {
transition:all linear 0.15s;
color:#FFF;
}
.menu > ul > li {
float:left;
display:inline-block;
position:relative;
font-size:19px;
}
.menu > ul > li > a {
padding:10px 30px;
display:inline-block;
text-shadow:0px 1px 0px rgba(0,0,0,0.4);
text-decoration:none;
}
.menu > ul > li:hover > a { /* Hover background color */
background:#5D9390;
}
.menu li:hover .sub-menu {
opacity:1;
}
.sub-menu {
width: 100%;
padding:5px 0px;
position:absolute; /* Need this so menu height doesnt extend to dropdown size*/
top:100%;
left:0px;
z-index:-1;
opacity:0;
transition:opacity linear 0.15s;
background:#6D9E9B;
}
.sub-menu li {
display:block;
font-size:16px;
}
.sub-menu li a {
padding:10px 30px;
display:block;
text-decoration:none;
}
.sub-menu li a:hover {
background:#5D9390;
}
I think that is the only relevant code needed, I've kinda lost my mind a bit and put margin auto in too many spots to try fix this but none of it is working
First of all change the
.menu-wrap {
width: 80%;
background: #85D2CD;
display: block;
margin: 0 auto;
overflow: hidden;
}
And to center your menu items, change the ul style to
ul.sub-menu {
text-align: center;
}
That should get the things sorted out and be aligned in middle.
If you know the width of the wrapping div, you can do this:
.menu-wrap{
left: 10%;
position: relative;
}
If you get rid of the float:left, you can add this to the menu, to center the menu:
.menu {
text-align: center;
}
JsFiddle: http://jsfiddle.net/d8sstx6t/2/
If you don't know the width and the height of the content you can use display: table;
.clearfix:after {
display:block;
clear:both;
}
.menu-wrap ul {
margin:0px;
padding:0px;
}
.menu-wrap {
width:80%;
background: #85D2CD;
display: table;
margin: 0 auto;
}
.menu {
display: table;
margin:0 auto;
}
.menu li {
margin:0px;
list-style:none;
}
.menu a {
transition:all linear 0.15s;
color:#FFF;
}
.menu > ul > li {
float:left;
display:inline-block;
position:relative;
font-size:19px;
}
.menu > ul > li > a {
padding:10px 30px;
display:inline-block;
text-shadow:0px 1px 0px rgba(0,0,0,0.4);
text-decoration:none;
}
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li>Home</li>
<li>Second Page</li>
<li>Third Page<span class="arrow">▼</span>
<ul class="sub-menu">
<li>Dropdown One</li>
<li>Dropdown Two</li>
</ul>
</li>
<li>Fourth Page</li>
<li>Fifth Page<span class="arrow">▼</span>
<ul class="sub-menu">
<li>Dropdown 1</li>
<li>Dropdown Item 2</li>
<li>Dropdown 3</li>
<li>Dropdown 4</li>
</ul>
</li>
</ul>
</nav>
How do I make a div menu button drop down and add sub menus to it using only HTML & CSS.
HTML:
<div class="right_menu">Change Password
Sign Out
</div>
CSS:
.sign_out_button{
background-color: #2fa4e7;
padding-top: 16px;
padding-bottom: 16px;
padding-left:10px;
padding-right:10px;
color: #FFF;
float: left;
text-decoration: none;
}
.sign_out_button:hover{background-color:#1892d7;}
.sign_out_button a{color:#FFF;
text-decoration: none;}
Here is another choise without javascript and it works fine too
<ul>
<li>
Menu
<ul>
<li>Submenu</li>
<li>Submenu</li>
<li>Submenu</li>
</ul>
</li>
</ul>
This is your html, insert to your page. Now comes the CSS
ul {
width:200px;
text-align: left;
display: inline;
margin: 0;
padding: 15px 4px 17px 0;
list-style: none;
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
}
ul li {width:200px;
font: bold 12px/18px sans-serif;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 15px 20px;
background: #fff;
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;
}
ul li:hover {
background: #555;
color: #fff;
}
ul li ul {
padding: 0;
position: absolute;
top: 48px;
left: 0;
width:200px;
-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 {
background: #555;
display: block;
color: #fff;
text-shadow: 0 -1px 0 #000;
}
ul li ul li:hover { background: #666; }
ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
And here you got a demo of that
https://jsfiddle.net/r50kbnq7/
I linked a jsfiddle below, have a look.
CSS:
#primary_nav_wrap
{
margin-top:15px
}
#primary_nav_wrap ul
{
list-style:none;
position:relative;
float:left;
margin:0;
padding:0
}
#primary_nav_wrap 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_nav_wrap ul li
{
position:relative;
float:left;
margin:0;
padding:0
}
#primary_nav_wrap ul li.current-menu-item
{
background:#ddd
}
#primary_nav_wrap ul li:hover
{
background:#f6f6f6
}
#primary_nav_wrap ul ul
{
display:none;
position:absolute;
top:100%;
left:0;
background:#fff;
padding:0
}
#primary_nav_wrap ul ul li
{
float:none;
width:200px
}
#primary_nav_wrap ul ul a
{
line-height:120%;
padding:10px 15px
}
#primary_nav_wrap ul ul ul
{
top:0;
left:100%
}
#primary_nav_wrap ul li:hover > ul
{
display:block
}
HTML:
<h1>Simple Pure CSS Drop Down Menu</h1>
<nav id="primary_nav_wrap">
<ul>
<li class="current-menu-item">Home</li>
<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
<ul>
<li>Sub Deep 1</li>
<li>Sub Deep 2</li>
<li>Sub Deep 3</li>
<li>Sub Deep 4</li>
</ul>
</li>
<li>Deep Menu 2</li>
</ul>
</li>
<li>Sub Menu 5</li>
</ul>
</li>
<li>Menu 2
<ul>
<li>Sub Menu 1</li>
<li>Sub Menu 2</li>
<li>Sub Menu 3</li>
</ul>
</li>
<li>Menu 3
<ul>
<li class="dir">Sub Menu 1</li>
<li class="dir">Sub Menu 2 THIS IS SO LONG IT MIGHT CAUSE AN ISSEUE BUT MAYBE NOT?
<ul>
<li>Category 1</li>
<li>Category 2</li>
<li>Category 3</li>
<li>Category 4</li>
<li>Category 5</li>
</ul>
</li>
<li>Sub Menu 3</li>
<li>Sub Menu 4</li>
<li>Sub Menu 5</li>
</ul>
</li>
<li>Menu 4</li>
<li>Menu 5</li>
<li>Menu 6</li>
</ul>
</nav>
http://jsfiddle.net/p9mrdk1d/
This is Very simple. here it is a simple code.........
===============HTML=================
<ul id="menu">
<li><span>HerĹa 1</span></li>
<li><span>HerĹa 2</span></li>
<li><span>HerĹa 3</span>
<ul>
<li><span>Level 2-A-1</span>
<ul>
<li><span>Level 3-A-1</span>
<ul>
<li><span>Level 4-A-1</span>
<ul>
<li><span>Level 5-A-1</span></li>
</ul>
</li>
<li><span>Level 4-A-2</span></li>
</ul>
</li>
<li><span>Level 3-A-2</span></li>
<li><span>Level 3-A-3</span></li>
</ul>
</li>
<li><span>Level 2-A-2</span></li>
<li><span>Level 2-A-3</span></li>
<li><span>Level 2-A-4</span></li>
</ul>
</li>
</ul>
=============CSS================
* {
list-style:none;
margin:0;
padding:0;
font-size:1em;
cursor:pointer;
}
#menu{
margin:3px;
}
#menu > li{ /* Top Level */
float:left;
margin-right:3px;
}
#menu > li > span{
display:block;
background:#0ac;
padding:3px 10px;
}
#menu > li:hover > span{
color:#fff;
}
#menu > li > ul{ /* Second Level */
display:none;
background:#08a;
}
#menu > li:hover > ul{
display:block;
position:absolute;
}
#menu > li > ul > li > span{
display:block;
padding:3px 10px;
border-top:solid 3px #fff;
}
#menu > li > ul > li:hover > span{
color:#fff;
}
#menu > li > ul li > ul{ /* Third Level & beyond */
display:none;
background:#068;
}
#menu > li > ul li:hover > ul{
display:block;
position:absolute;
left:100%;
border-left:solid 3px #fff;
top:0;
width:auto;
}
#menu > li > ul > li ul > li{
display:block;
padding:3px 10px;
border-top:solid 3px #fff;
white-space:nowrap;
}
#menu > li > ul > li ul > li:hover > span{
color:#fff;
}
I created a fiddle with my own div menu with dropdown. You can add icons to it and change as you need it. You need to use jquery. I will add later another without jquery.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<div class="LEFT-MENU">
<ul>
<li>
MENU 1
<ul class="LEFT-SUBMENU">
<li>SUBMENU 1</li>
<li>SUBMENU 2</li>
<li>SUBMENU 3</li>
<li>SUBMENU 4</li>
</ul></li>
</ul></div>
https://jsfiddle.net/1tueu0tq/
Click there and watch the demo. If you like it just copy and paste to your site
i have a menu that when i hover has a drop down i follow this
and this but unfortunately im getting different result than expected..im getting list but it is displayed as line horizontally and not vertically like the example here is the code i added to make the drop down
css
ul # menu li ul .submenu{
display:none;
}
ul # menu li : hover ul .submenu{
display:block;
}
here is the html
<div id="menu">
<ul id="menu-list">
<li id="">Home</li>
<li id="">
Menu
<ul class="sub-menu">
<li>Sub Menu 1</li>
<li>Sub Menu 2</li>
<li>Sub Menu 3</li>
<li>Sub Menu 4</li>
</ul>
</li>
<li id="">Menu</li>
<li id="">Menu</li>
<li id="">Menu</li>
</ul>
</div>
Here you go:
Updated Fiddle
Just the small change. Made UL id = "menu"
<ul id="menu">
<li id="home">Home</li>
<li id="townoffice">
Menu
<ul class="sub-menu">
<li>Sub Menu 1</li>
<li>Sub Menu 2</li>
<li>Sub Menu 3</li>
<li>Sub Menu 4</li>
</ul>
</li>
<li id="busines">Menu</li>
<li id="residents">Menu</li>
<li id="tourists">Menu</li>
</ul>
HTML
<ul id="nav" class="sixteen columns">
<li>Home
</li>
<li>Portfolio
<ul>
<li>Asia
<ul>
<li>Korea</li>
<li>China</li>
<li>Japan</li>
</ul>
</li>
<li>Europe
<ul>
<li>France</li>
<li>Germany</li>
<li>Italy</li>
</ul>
</li>
</ul>
</li>
</ul>
CSS
#nav {
width:800px;
margin:30px 50px;
padding: 0;
float:left;
}
#nav li {
list-style: none;
float: left;
padding:0 10px;
background-color:#367FB3;
color:white;
}
#nav li a:hover {
background-color:#52baff;
color:#fff;
}
//daf adf
/*--temp--*/
#nav ul ul li {
clear:left;
}
#nav ul ul {
position:absolute;
left:14em;
top:0;
}
#nav ul ul li a {
display:block;
padding: 3px 15px;
color: #242424;
text-decoration: none;
font-size:13px;
font-family:"Lato" !important;
}
/*--end temp--*/
#nav li a {
display: block;
padding: 3px 15px;
color: #242424;
text-decoration: none;
font-size:13px;
font-family:"Lato" !important;
}
#nav a:hover {
color:#367FB3;
}
#nav a:active {
color:#367FB3;
}
#nav li ul {
display: none;
width: 14em;
/* Width to help Opera out */
background-color:transparent;
z-index:666;
}
#nav li:hover ul, #nav li.hover ul {
display: block;
position: absolute;
margin:0px -10px;
padding:0px;
}
#nav li:hover ul ul {
display:none;
}
#nav li ul li:hover ul {
display:block
}
#nav li:hover li, #nav li.hover li {
float: none;
line-height:30px;
}
#nav li:hover li a, #nav li.hover li a {
background-color:#367FB3;
color:#fff;
font-size:13px;
font-family:"Lato" !important;
}
#nav li li a:hover {
background-color:#52baff;
color:#fff;
}
FIDDLE