Show Submenu when hover - hover

I'm new in jQuery and I need to show the submenu when the cursor hovers.
this is my code:
<li class="menu">
Qui sommes nous?
<ul class="submenu">
<li>Notre histoire</li>
<li>Notre philosophie</li>
</ul>
</li>

You can do that with css, using visbility style.
There is example :
ul
{
position:relative; /*need for properly .submenu positioning */
margin:0; padding:0;
}
li
{
list-style-type:none; /*remove style type (circles) for all li*/
}
.menu
{
display:inline-block;
}
/*submenu will be placed under parent li and hidden, until .menu is hovered*/
.submenu
{
visibility:hidden;
position:absolute;
top:100%;
}
/*on hover .menu, .submenu will be showed*/
.menu:hover > .submenu
{
visibility:visible;
}
<ul>
<li class="menu">
Qui sommes nous?
<ul class="submenu">
<li>Notre histoire</li>
<li>Notre philosophie</li>
</ul>
</li>
<li class="menu">
Qui sommes nous?
<ul class="submenu">
<li>Notre histoire</li>
<li>Notre philosophie</li>
</ul>
</li>
<ul>

This can be done using pure CSS. Try this:
.submenu {
height: 0;
width: auto;
background: url(../../../themes/images/...png) repeat;
position: relative;
top: 15px;
line-height: 11px;
}
.submenu li {
height: 12px;
font-size: 12px;
color: #FFF;
padding: 15px;
padding-right: 5px;
font-family: Arial, Helvetica, sans-serif;
display: none;
cursor: pointer;
}
.submenu li:hover {
color: #FFF;
background: #A526CA;
}

Related

Add a vertical Sub menu using css and html

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 &#9662
<ul class="subs">
<li>Tenants List</li>
<li>Users List</li>
<li>Tenant Rental</li>
</ul>
</li>
<li>REPORTS &#9662
<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 &#9662
<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

Trying to create a drop down list in CSS3

I've been trying to work on this with no success, for some reason the sub list is just not showing up! I've tried: nav > ul > li:hover > ul{} but that seems to break functionality of the code. I'm sure this is a pretty simple issue I'm having.
nav > ul {
list-style: none;
}
nav > ul > li {
padding: 20px;
float: left;
}
nav > ul > li {
background-color: #fff;
}
nav > ul > ul {
display: none;
position: absolute;
top: 100%;
left: 0;
padding: 0;
}
nav > ul > ul > li {
float: none;
width: 200px;
}
nav > ul > li:hover {
color: #4169E1;
display: block;
visibility: visible;
}
body {
background: black;
}
<nav>
<ul>
<li>Home</li>
<li>About Us</li>
<li>Secure</li>
<ul>
<li>How secure are we?</li>
<li>We are not secure enough!!</li>
</ul>
<li>Mad</li>
</ul>
</nav>
Simplify your selectors (nav ul ul) is fine
Make the parent li's position: relative so that the position: absolute dropdowns are positioned in relation to them. Use an appropriate top value
In your example, visibility: visible is not doing anything. display: none and display: block are used to hide / show
Nest your lists properly. This is the correct way:
<ul>
<li>Top Menu Item
<ul>
<li>Sub-menu Item</li>
</ul>
</li>
</ul>
Read more: Nested lists on w3.org
CSS / HTML / Demo
* {
margin: 0;
padding: 0;
}
nav ul {
list-style: none;
padding: 0;
}
nav ul li {
padding: 20px;
float: left;
background-color: #fff;
position: relative;
}
nav ul ul {
display: none;
position: absolute;
top: 100%;
left: 0;
padding: 0;
}
nav ul ul li {
width: 200px;
background: #FFF;
padding: 10px;
}
nav ul li:hover ul {
color: #4169E1;
display: block;
}
body {
background: black;
}
<nav>
<ul>
<li>Home</li>
<li>About Us
<ul>
<li>This is us!</li>
<li>This is us!</li>
<li>This is us!</li>
<li>This is us!</li>
</ul>
</li>
<li>Secure
<ul>
<li>How secure are we?</li>
<li>We are not secure enough!!</li>
</ul>
</li>
<li>Mad</li>
</ul>
</nav>
To Point out one of the Mistakes you have
<ul>
<li>Home</li>
<li>About Us</li>
<li>Secure
<ul> **--> this should be inside li**
<li>How secure are we?</li>
<li>We are not secure enough!!</li>
</ul>
</li>
<li>Mad</li>
</ul>
and your css
add this
nav > ul > li:hover > ul{
display: block;
opacity: 1;
visibility: visible;
}
check the fiddle
http://jsfiddle.net/ruchan/4fk6y2wu/
Use some more css3 power!
See Demo here
See Fullscreen
<nav>
<ul id="menu">
<li class="category top_level"><a class="selected" href="#">Home</a></li>
<li class="category top_level">About</li>
<li class="category top_level">Secure
<ul class="dropdown">
<li class="item">How secure are we?</li>
<li class="item">We are not secure enough!!</li>
</ul>
</li>
<li class="category top_level last">Mad
</li>
</ul>
</nav>
css
body {
font-family:'Montserrat', sans-serif;
background:#000;
}
ul {
list-style-type: none;
}
#menu a {
text-decoration: none;
white-space: nowrap;
color: #222;
background-color: #fff;
}
#menu li.top_level {
vertical-align: top;
zoom: 1;
display: block;
float: left;
width: 16.5%;
margin-right: 0.2%;
position: relative;
text-align:center;
}
#menu li.last {
margin-right: 0px;
}
#menu .dropdown {
float: none;
z-index: 100;
position: absolute;
width: 100%;
height: 0;
overflow: hidden;
}
#menu .category:hover .dropdown, #menu .category:focus .dropdown {
height:auto;
}
#menu .item a, #menu .category a, #menu .category a:visited, #menu .item a:visited {
line-height:2em;
display:block;
padding:.6em;
border-top: #ffffff 2px solid;
}
#menu .item a:hover, #menu .category a:hover, #menu .item a:focus, #menu .category a:focus {
background:#007dac;
-webkit-transition: background-color 940ms;
-moz-transition: background-color 940ms;
}
#menu a.selected {
color: #ffffff;
background-color: #007dac;
}

How do I put the menu next to the logo?

Screenshot of the header that's needing this work:
As you can see, the menu is below the logo. I was wanting the menu beside it, to the right of the logo. I don't know if it's possible, but if it is, I could use some help, please.
Here's the code for everything, separated for your convenience.
The menu and logo in their divs:
<div id="wrapper">
<div id="body-wrapper">
<div class="head">
<div class="head-wrapper">
<div class="logo">
<img src="http://i.imgur.com/sDnntOE.png">
<ul>
<li>Home</li>
<li>About Us
<ul>
<li>The Team</li>
<li>History</li>
</ul>
</li>
<li>Products
<ul>
<li>Chaotix Browser</li>
<li>Useful Beta 1.7.5</li>
<li>Chaotix Cleaner 1.4</li>
<li>Forum</li>
<li>CDev</li>
<li>Infinite-PVP</li>
<li>Ulta-Craft</li>
</ul>
</li>
<li>Contact Us
<ul>
<li>E-Mail</li>
<li>News Letter</li>
<li>Social Mediar</li>
</ul>
</li>
<li>Divisions
<ul>
<li>Gaming</li>
<li>Films</li>
</ul>
</li>
<li>Chaotix! Forum</li>
<li>Partnerships
<ul>
<li>GameFanShop</li>
<li>Forumotion</li>
</ul>
</li>
</ul>
The CSS:
<style>
*{
background-image:url('http://i.imgur.com/0u7sBsT.png');
background-color:#999999;
font-family:Tahoma;color:white;
}
div.head{
text-align:Center;
padding-top:10px;
}
div.body{
padding-top:100px;
padding-left:300px;
padding-right:300px;
text-align:center;
}
div.logo{
float:left;
}
a{
color:white;
}
a:hover{
color:gray;
}
/* Main menu
------------------------------------------*/
ul{
font-family: Lato,Tahoma,Arial, Verdana;
font-size: 14px;
margin: 0;
padding: 0;
list-style: none;
padding-left:25px;
}
ul li{
display: block;
position: relative;
float: left;
}
li ul{
display: none;
}
ul li a{
display: block;
text-decoration: none;
color: #FFFFFF;
border-top: 1px solid #000000;
padding: 5px 15px 5px 15px;
background: #000000;
margin-left: 1px;
white-space: nowrap;
}
ul li a:hover{
background: #999999;
}
li:hover ul{
display: block;
position: absolute;
}
li:hover li{
float: none;
font-size: 11px;
}
li:hover a{
background: #000000;
}
li:hover li a:hover{
background: #999999;
}
</style>
Add your css
.logo img
{
float:left;
}
.logo ul
{
float:left;
}
It working ok. Hope this help!

CSS dropdown menu vertically

I have this site here http://surfthecurve.ca/ and I have a navigation for each nav item there is a drop down menu, the menu works fine, I just cant seem to get it to go vertically.
Here is the CSS for the navigation
.navigation{
width:100%;
background-color:#353636;
font-size:18px;
float:left;
}
.navigation ul {
list-style-type: none;
margin: 0 auto;
width:825px;
}
.navigation li {
float: left;
}
.navigation ul a {
color: #ffffff;
display: block;
padding: 0 105px 0 0;
text-decoration: none;
width:100%;
text-align:center;
text-transform:uppercase;
}
and the CSS for the drop-down
.submenu {
display: none;
}
.submenu li a {
display: block;
text-decoration: none;
color: #ffffff;
padding: 5px 15px 5px 15px;
margin-left: 1px;
white-space: nowrap;
}
.navigation li:hover .submenu {
display: block;
position: absolute;
}
.navigation li:hover .submenu li {
float: left;
font-size: 13px;
}
ul li a:hover {
background: #353636;
}
li:hover a {
background: #353636;
}
li:hover li a:hover {
background: #353636;
}
.navigation ul li ul li a{
padding-left:10px !important;
padding-right:10px !important;
padding-top:0px !important;
padding-bottom:0px !important;
}
and here is the HTML
<div class="navigation">
<ul>
<li>tutoring
<ul class="submenu">
<li>Our Approach</li>
<li>Pricing</li>
</ul>
</li>
<li>the cause
<ul class="submenu">
<li>How It Works</li>
<li>How We Give</li>
<li>Why We Give</li>
</ul>
</li>
<li>company
<ul class="submenu">
<li>About Us</li>
<li>Let's Get In Touch</li>
</ul>
</li>
<li>get involved
<ul class="submenu">
<li>Students</li>
<li>Work For Us</li>
</ul>
</li>
</ul>
</div><!--navigation-->
How would I fix this for my menu goes vertically?
Thanks in advanced,
J
This should be easy enough to get it to display vertically:
.submenu li {
clear: both;
}
What you have to do now is style it, as the individual li elements are different sizes (the element shrink wraps to the size of the text).

Why does this menu navigation <div> not centre align?

I have a website with a drop down navigation bar at the top, I would like to centre the navigation bar, but I can't get it to work, it seems to be stuck to the left side. You can view the website here and I've pasted the code below.
I've been trying to get this to work all day, but I can't see where the problem is. I don't know what more to write, any help would be greatly appreciated.
My style.css:
#menu{
position: absolute;
z-index: 1;
padding:0;
margin: auto;
}
#menu ul{
padding:0;
margin:0;
margin: auto;
text-align: center;
display: inherit;
}
#menu li{
position: relative;
float: left;
list-style: none;
margin: 0;
padding:0;
}
#menu li a{
width:100px;
height: 30px;
display: block;
text-decoration:none;
text-align: center;
line-height: 30px;
background-color: white;
color: #7B99FF;
font-size: 16px;
}
#menu li a:hover{
color: #000;
}
#menu li .subnav a {
color: #7B99FF;
font-size: 13px;
}
#menu li .subnav a:hover{
color: #000;
font-size: 13px;
}
#menu ul ul{
position: absolute;
top: 30px;
visibility: hidden;
}
#menu ul li:hover ul{
visibility:visible;
}
.subnav {
font-size: 13px;
}
My index.php:
<div id="menu">
<ul>
<li>About me
</li>
<li>Categories
<ul class="subnav">
<li>Link 2-1</li>
<li>Link 2-2</li>
<li>Link 2-3</li>
</ul>
</li>
<li>Archive
<ul class="subnav">
<li>Link 3-1</li>
<li>Link 3-2</li>
<li>Link 3-3</li>
</ul>
</li>
<li>Contact
</li>
</ul>
</div>
Remove the 'absolute' position of #menu and give it some width:
#menu{
width:400px;
z-index: 1;
padding:0;
margin: auto;}
If you don't want to set width manually you can wrap your root in a div with style:
text-align:center