How I make my Dropdown Menu Fade-In Using CSS - html

#menu {
width: 100%;
margin: 10px auto;
}
#menu ul,
#menu li {
margin: 0 auto;
padding: 0 0;
list-style: none
}
#menu ul {
width: 100%;
}
#menu li {
float: left;
display: inline;
position: relative;
}
#menu a {
display: block;
line-height: 35px;
padding: 0 14px;
text-decoration: none;
}
#menu li a {
border-right: 1px solid #e5e5e5;
}
#menu li a:hover {
color: #444;
background-color: #e5e5e5;
}
#menu input {
display: none;
margin: 0 0;
padding: 0 0;
width: 80px;
height: 30px;
opacity: 0;
}
#menu label {
font-size: 20px;
display: none;
width: 35px;
height: 20px;
line-height: 20px;
text-align: center;
color: #77778b
}
#menu label span {
position: absolute;
left: 35px;
}
#menu ul.menus {
height: auto;
overflow: hidden;
width: 180px;
border-top: 1px solid #e5e5e5;
border-left: 1px solid #e5e5e5;
border-bottom: 1px solid #e5e5e5;
position: absolute;
z-index: 99;
display: none;
left: -1px;
}
#menu ul.menus li {
display: block;
width: 100%;
}
#menu ul.menus a {
color: #77778b;
}
#menu li:hover ul.menus {
display: block
}
<nav id='menu'>
<input type='checkbox' />
<label><i class='icon-reorder' /><span>Menu</span>
</label>
<ul>
<li><a href='/'>Home</a>
</li>
<li><a class='dropdown' href='#'>Menu1</a>
<ul class='menus'>
<li><a href='#'>Submenu1</a>
</li>
<li><a href='#'>Submenu2</a>
</li>
</ul>
</li>
<li><a class='dropdown' href='#'>Menu2</a>
<ul class='menus'>
<li><a href='#'>Submenu1</a>
</li>
<li><a href='#'>Submenu2</a>
</li>
<li><a href='#'>Submenu3</a>
</li>
</ul>
</li>
</ul>
</nav>
How can I make the Dropdowns Fade in with only CSS? A bit noobish question but still trying to understand CSS Any one have any idea how to make it possible plz suggest it.
Thanks !

One possible solution is to use opacity: 0 instead of display: none and using transition on hover:
#menu {
width: 100%;
margin: 10px auto;
}
#menu ul,
#menu li {
margin: 0 auto;
padding: 0 0;
list-style: none
}
#menu ul {
width: 100%;
}
#menu li {
float: left;
display: inline;
position: relative;
}
#menu a {
display: block;
line-height: 35px;
padding: 0 14px;
text-decoration: none;
}
#menu li a {
border-right: 1px solid #e5e5e5;
}
#menu li a:hover {
color: #444;
background-color: #e5e5e5;
}
#menu input {
display: none;
margin: 0 0;
padding: 0 0;
width: 80px;
height: 30px;
opacity: 0;
}
#menu label {
font-size: 20px;
display: block;
width: 35px;
height: 20px;
line-height: 20px;
text-align: center;
color: #77778b;
visibility: hidden;
}
#menu label span {
position: absolute;
left: 35px;
}
#menu ul.menus {
height: auto;
overflow: hidden;
width: 180px;
border-top: 1px solid #e5e5e5;
border-left: 1px solid #e5e5e5;
border-bottom: 1px solid #e5e5e5;
position: absolute;
z-index: 99;
display: block;
left: -1px;
opacity: 0;
}
#menu ul.menus li {
display: block;
width: 100%;
}
#menu ul.menus a {
color: #77778b;
}
#menu li:hover ul.menus {
opacity: 1;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-ms-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}
<nav id='menu'>
<input type='checkbox' />
<label><i class='icon-reorder' /><span>Menu</span>
</label>
<ul>
<li><a href='/'>Home</a>
</li>
<li><a class='dropdown' href='#'>Menu1</a>
<ul class='menus'>
<li><a href='#'>Submenu1</a>
</li>
<li><a href='#'>Submenu2</a>
</li>
</ul>
</li>
<li><a class='dropdown' href='#'>Menu2</a>
<ul class='menus'>
<li><a href='#'>Submenu1</a>
</li>
<li><a href='#'>Submenu2</a>
</li>
<li><a href='#'>Submenu3</a>
</li>
</ul>
</li>
</ul>
</nav>
Also you can use transition same way to animate on mouse out:
#menu {
width: 100%;
margin: 10px auto;
}
#menu ul,
#menu li {
margin: 0 auto;
padding: 0 0;
list-style: none
}
#menu ul {
width: 100%;
}
#menu li {
float: left;
display: inline;
position: relative;
}
#menu a {
display: block;
line-height: 35px;
padding: 0 14px;
text-decoration: none;
}
#menu li a {
border-right: 1px solid #e5e5e5;
}
#menu li a:hover {
color: #444;
background-color: #e5e5e5;
}
#menu input {
display: none;
margin: 0 0;
padding: 0 0;
width: 80px;
height: 30px;
opacity: 0;
}
#menu label {
font-size: 20px;
display: block;
width: 35px;
height: 20px;
line-height: 20px;
text-align: center;
color: #77778b;
visibility: hidden;
}
#menu label span {
position: absolute;
left: 35px;
}
#menu ul.menus {
height: auto;
overflow: hidden;
width: 180px;
border-top: 1px solid #e5e5e5;
border-left: 1px solid #e5e5e5;
border-bottom: 1px solid #e5e5e5;
position: absolute;
z-index: 99;
display: block;
left: -1px;
opacity: 0;
-webkit-transition: opacity 0.5s ease-in-out;
-moz-transition: opacity 0.5s ease-in-out;
-ms-transition: opacity 0.5s ease-in-out;
-o-transition: opacity 0.5s ease-in-out;
transition: opacity 0.5s ease-in-out;
}
#menu ul.menus li {
display: block;
width: 100%;
}
#menu ul.menus a {
color: #77778b;
}
#menu li:hover ul.menus {
opacity: 1;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-ms-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}
<nav id='menu'>
<input type='checkbox' />
<label><i class='icon-reorder' /><span>Menu</span>
</label>
<ul>
<li><a href='/'>Home</a>
</li>
<li><a class='dropdown' href='#'>Menu1</a>
<ul class='menus'>
<li><a href='#'>Submenu1</a>
</li>
<li><a href='#'>Submenu2</a>
</li>
</ul>
</li>
<li><a class='dropdown' href='#'>Menu2</a>
<ul class='menus'>
<li><a href='#'>Submenu1</a>
</li>
<li><a href='#'>Submenu2</a>
</li>
<li><a href='#'>Submenu3</a>
</li>
</ul>
</li>
</ul>
</nav>

Related

css position absolute menu top [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I am trying add notification icon, but is overflow text and dont on left.
Here is my code (run the snippet to see the result):
.dropdown {
display: inline-block;
cursor: pointer;
border: 1px solid #fff;
}
.dropdown:hover {
color: #e1a900;
}
.dropdown-content {
background-color: #333333;
display: none;
position: relative;
min-width: 180px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
margin-top: 64px;
}
.dropdown-content a {
color: #fff;
font-weight: bold;
padding: 12px 12px;
text-decoration: none;
display: block;
-o-transition:color .2s ease-out, background .3s ease-in;
-ms-transition:color .2s ease-out, background .3s ease-in;
-moz-transition:color .2s ease-out, background .3s ease-in;
-webkit-transition:color .2s ease-out, background .3s ease-in;
transition:color .2s ease-out, background .3s ease-in;
}
.dropdown-content a:hover {background-color: #cc9900;}
.dropdown:hover .dropdown-content {display: block;}
.bellimg {
padding-top: 5px;
}
.bellnumbers {
font-size:12px;
background-color:red;
width:16px;
line-height: 16px;
text-align: center;
color:#fff;
z-index: 2;
border-radius: 3px;
position: absolute;
left: 30px;
}
.bell {
border: 1px solid #fff;
width: 48px;
height: 42px;
left: 30;
position: absolute;
}
.notificationicon {
position: absolute;
top: 0px;
right: 0px;
border: 1px solid #fff;
}
/********************************
* Menu Styles *
*********************************/
#menu {
height: 64px;
width: 450px;
}
#menu ul,#menu li {
margin: 0;
padding: 0;
list-style: none;
}
#menu li {
float: left;
display: inline;
position: relative;
}
#menu li a {
color: #fff;
font-weight: bold;
-o-transition: color .2s ease-out, background .3s ease-in;
-ms-transition: color .2s ease-out, background .3s ease-in;
-moz-transition: color .2s ease-out, background .3s ease-in;
-webkit-transition: color .2s ease-out, background .3s ease-in;
transition: color .2s ease-out, background .3s ease-in;
}
#menu a {
display: block;
line-height: 35px;
padding: 14px 10px 14px 5px;
text-decoration: none;
color: #fff;
border-bottom: 1px solid #000;
}
#menu li:hover > a,#menu li a:hover {
color: #fff;
background-color: #e1a900;
}
#menu input {
display: none;
margin: 0 0;
padding: 0 0;
width: 80px;
height: 35px;
opacity: 0;
cursor: pointer;
}
#menu label {
display: none;
width: 35px;
height: 36px;
line-height: 36px;
text-align: center;
}
#menu label span {
font-size: 13px;
position: absolute;
left: 35px;
}
#menu ul.menus {
/*background sub menus*/
height: auto;
overflow: hidden;
width: 180px;
background-color: #333333;
position: absolute;
z-index: 99;
display: none;
border: 1px solid #000;
border-top: none;
color: #fff;
}
#menu ul.menus a {
color: #fff;
padding: 0px;
}
#menu ul.menus li {
display: block;
width: 100%;
text-transform: none;
}
#menu li:hover ul.menus {
display: block;
border-top: 2px solid red;
border-bottom: 2px solid red;
}
#menu a.prett {
padding: 14px 19px 14px 5px;
}
#menu li:hover > a.prett,#menu a.prett:hover {
/*DropDown list background color*/
background: #e1a900;
color: #fff;
}
#menu a.prett::after {
content: "";
width: 0;
height: 0;
border-width: 6px 5px;
border-style: solid;
border-color: #eee transparent transparent transparent;
position: absolute;
top: 30px;
right: 4px;
}
#menu ul.menus a:hover {
/*Dropdown menu background color*/
background: #e1a900;
}
#media screen and (max-width: 1000px){
#menu {width: 150px;}
#menu a {padding: 0px; border-bottom: 1px solid #000;}
#menu a.prett {padding: 0px;}
#menu a.prett::after {top: 15px;right: 4px;}
#menu{position:relative;margin-top:0;}
#menu ul{background-color: #333333;position:absolute;top:100%;right:0;left:0;z-index:3;height:auto;display:none;}
#menu ul.menus{width:100%;position:static;border:none; border-top: 2px solid red; border-bottom: 2px solid red;}
#menu li{display:block;float:none;width:auto;text-align:left}
#menu li a{color:#fff}
#menu li a:hover{color:#333}
#menu li:hover{background:#e1a900;color:#fff;}
#menu li:hover > a.prett,#menu a.prett:hover{background:#BABABA;color:#333;}
#menu ul.menus a{background-color: #4d4d4d;}
#menu ul.menus a:hover{background:#e1a900;}
#menu input,#menu label{position:absolute;top:0;left:0;display:block;margin-top: 15px;}
#menu input{z-index:4}
#menu input:checked + label{color:#e1a900; background-color: #404040;}
#menu input:checked ~ ul{display:block;}
}
.menu_head {
width: 100%;
height: 64px;
background-color: #000;
background-image: url("../images/menu.png");
box-shadow: 0 3px 6px rgba(0,0,0, .8);
background-position: top;
text-align: center;
padding-left: 10px;
padding-right: 10px;
position: fixed;
top: 0;
color: #fff;
z-index:1;
font-weight: bold;
border: 1px solid #fff;
}
<div class='menu_head'>
<!-- MENU LEFT -->
<nav id='menu' style='border: 1px solid #fff;'>
<input type='checkbox'/>
<label>≡<span>MENU</span></label>
<ul>
<li><a href=''>Home</a></li>
<li><a class='prett' href='' onclick='return false;'>Rules</a>
<ul class='menus'>
<li><a href='#'>Rules </a></li>
</ul>
</li>
<li><a class='prett' href='' onclick='return false;'>Suporte</a>
<ul class='menus'>
<li><a href='#'>Terms of Service</a></li>
</ul>
</li>
</ul>
</nav>
<div class='notificationicon'>
<span class='bell'>
<img class='bellimg' src='../images/notification.png'/>
<span class='bellnumbers'>10</span>
</span>
<span class='dropdown'>
<div style='float: right; line-height: 64px; margin-right:15px;'>Welcome asd asd asd asd x3G</div>
<div class='dropdown-content'>
<a href=''>PROFILE</a>
<a href=''>TEAM</a>
<a href=''> SETINGS</a>
<a href=''>BALANCE</a>
<a href=''> INBOX</a>
<a href=''> LOG OUT</a>
</div>
</span>
<div style='clear:both;'></div>
</div>
<div style='clear:both;'></div>
</div>
On the .bell class you have defined the left property value without a unit, for example px (See image below for reference)
Simply add a unit like px or % and it should work:
.bell {
left: 30px;
}

How can create a dropdown without using absolute or negative value

I have a task to create a drop-down menu and i create it with using absolute and negative value but i can change my mind i want to create a drop-down without using absolute there is any possibility to create and how can do it kindly help in this query
.mainmenu {
position: relative;
cursor: pointer;
display: inline-block;
padding: 15px;
-webkit-transition: all .5s;
}
.submenu {
position: absolute;
height: 0px;
opacity: 0;
-webkit-transition: all .5s;
}
.mainmenu:hover {
border: 1px solid #000;
-webkit-transition: all .5s;
}
.mainmenu:hover .submenu {
border: 1px solid #000;
padding: 50px;
height: auto;
top: 100%;
left: -1px;
opacity: 1;
-webkit-transition: all .5s;
}
.mainmenu:hover .hide_line {
height: 5px;
width: 100%;
position: absolute;
top: 100%;
right: 0px;
background: #fff;
z-index: 1000;
}
<div class="mainmenu">
Menu
<div class="hide_line">
</div>
<div class="submenu">
submenu
</div>
</div>
You can use list for this purpose
.mainmenu a{
text-decoration:none;
color:#000000;
}
.mainmenu {
position: relative;
cursor: pointer;
display: inline-block;
padding: 15px;
-webkit-transition: all .5s;
list-style:none;
}
.mainmenu > li{
padding-left:0px;
margin-left:0px;
}
.submenu {
opacity:0;
list-style:none;
}
.mainmenu:hover .submenu {
border: 1px solid #000;
height: auto;
opacity: 1;
-webkit-transition: all .5s;
}
.submenu li{
padding-left:0px;
margin-left:0px;
}
<ul class="mainmenu">
<li><a href='#'>Main Menu</a>
<ul class="submenu">
<li><a href='#'>Sub menu</a></li>
</ul>
</li>
</ul>
I hope you can do rest of the formatting

Show child on parent hover instead of on parent OR child hover

I've created a simple dropdown menu that scales and fades in whenever I hover over the parent list item, "Services". Everything works as it should except for when I hover over the child element (dropdown menu) which also makes it appear. I understand that simply hiding it with opacity will not prevent a user from hovering over it but it allows for the 0.4s transition to take effect. If I were to hide it with display:none or visibility:hidden, the transition becomes instant. I'm considering using jQuery to solve this but was wondering if there is a solution based purely in CSS.
JSFiddle
* {
margin: 0;
padding: 0;
font-family: Montserrat;
}
li {
list-style: none;
}
a {
text-decoration: none;
}
nav {
background-color: white;
height: 60px;
display: flex;
justify-content: center;
align-items: center;
}
nav > ul > li {
display: inline-block;
position: relative;
height: 60px;
cursor: pointer;
}
nav a {
color: rgba(165,175,185,1);
}
nav > ul > li > a {
padding: 0 20px;
height: 100%;
line-height: 60px;
}
nav > ul > li:hover > a {
color: rgba(105,115,125,1);
}
nav > ul > li:first-of-type {
margin-right: auto;
}
.services-list-container {
position: absolute;
width: 200px;
top: 100%;
height: auto;
opacity: 0;
transform: rotateX(-20deg) scale(0.9,0.9);
transform-origin: 0 0;
transition: transform 0.4s ease, opacity 0.4s ease;
}
.services-list-container ul {
background-color: white;
box-shadow: 0 6px 16px rgba(40, 40, 90, 0.15);
position: relative;
margin-top: 30px;
}
.services-list-container a {
padding: 20px;
display: block;
}
.services-list-container a:hover {
padding: 20px;
display: block;
background-color: rgba(235,240,245,1);
}
.hover:hover .services-list-container {
transform: rotateX(0deg) scale(1,1);
opacity: 1;
transition: transform 0.4s ease, opacity 0.4s ease;
}
<nav>
<ul>
<li>
[Logo]
</li>
<li>
About
</li>
<li class="hover">
Services
<div class="services-list-container">
<ul>
<li>
Information
</li>
<li>
Technology
</li>
<li>
Training
</li>
<li>
Project Support
</li>
</ul>
</div>
</li>
<li>
News
</li>
<li>
Jobs
</li>
<li>
Contact
</li>
</ul>
</nav>
It's not that you are hovering over the child element, it's that your list elements are so tall from the height:60px that when you hover under the words, it's still going over the li element.
If you are targeting supporting browsers you can use pointer-events to prevent the submenu from causing a hover mouse event
Give your element pointer-events:none to disable
.services-list-container {
pointer-events:none;
position: absolute;
width: 200px;
top: 100%;
height: auto;
opacity: 0;
transform: rotateX(-20deg) scale(0.9,0.9);
transform-origin: 0 0;
transition: transform 0.4s ease, opacity 0.4s ease;
}
Then to make sure you can still enter the submenu, reset pointer-events while your .hover elements are hovered
.hover:hover .services-list-container {
pointer-events:all;
transform: rotateX(0deg) scale(1,1);
opacity: 1;
transition: transform 0.4s ease, opacity 0.4s ease;
}
Demo
* {
margin: 0;
padding: 0;
font-family: Montserrat;
}
li {
list-style: none;
}
a {
text-decoration: none;
}
nav {
background-color: white;
height: 60px;
display: flex;
justify-content: center;
align-items: center;
}
nav > ul > li {
display: inline-block;
position: relative;
height: 60px;
cursor: pointer;
}
nav a {
color: rgba(165,175,185,1);
}
nav > ul > li > a {
padding: 0 20px;
height: 100%;
line-height: 60px;
}
nav > ul > li:hover > a {
color: rgba(105,115,125,1);
}
nav > ul > li:first-of-type {
margin-right: auto;
}
.services-list-container {
pointer-events:none;
position: absolute;
width: 200px;
top: 100%;
height: auto;
opacity: 0;
transform: rotateX(-20deg) scale(0.9,0.9);
transform-origin: 0 0;
transition: transform 0.4s ease, opacity 0.4s ease;
}
.services-list-container ul {
background-color: white;
box-shadow: 0 6px 16px rgba(40, 40, 90, 0.15);
position: relative;
margin-top: 30px;
}
.services-list-container a {
padding: 20px;
display: block;
}
.services-list-container a:hover {
padding: 20px;
display: block;
background-color: rgba(235,240,245,1);
}
.hover:hover .services-list-container {
pointer-events:all;
transform: rotateX(0deg) scale(1,1);
opacity: 1;
transition: transform 0.4s ease, opacity 0.4s ease;
}
<nav>
<ul>
<li>
[Logo]
</li>
<li>
About
</li>
<li class="hover">
Services
<div class="services-list-container">
<ul>
<li>
Information
</li>
<li>
Technology
</li>
<li>
Training
</li>
<li>
Project Support
</li>
</ul>
</div>
</li>
<li>
News
</li>
<li>
Jobs
</li>
<li>
Contact
</li>
</ul>
</nav>
A combination of visibility:hidden; with the opacity changes helps you to keep that animation while still preventing it from triggering outside of the intended menu area:
https://jsfiddle.net/4wg4sbqy/
CSS:
* {
margin: 0;
padding: 0;
font-family: Montserrat;
}
li {
list-style: none;
}
a {
text-decoration: none;
}
nav {
background-color: white;
height: 60px;
display: flex;
justify-content: center;
align-items: center;
}
nav > ul > li {
display: inline-block;
position: relative;
height: 60px;
cursor: pointer;
}
nav a {
color: rgba(165,175,185,1);
}
nav > ul > li > a {
padding: 0 20px;
height: 100%;
line-height: 60px;
}
nav > ul > li:hover > a {
color: rgba(105,115,125,1);
}
nav > ul > li:first-of-type {
margin-right: auto;
}
.services-list-container {
position: absolute;
width: 200px;
top: 100%;
height: auto;
opacity: 0;
visibility: hidden;
transform: rotateX(-20deg) scale(0.9,0.9);
transform-origin: 0 0;
transition: transform 0.4s ease, opacity 0.4s ease;
}
.services-list-container ul {
background-color: white;
box-shadow: 0 6px 16px rgba(40, 40, 90, 0.15);
position: relative;
margin-top: 30px;
}
.services-list-container a {
padding: 20px;
display: block;
}
.services-list-container a:hover {
padding: 20px;
display: block;
background-color: rgba(235,240,245,1);
}
.hover:hover .services-list-container {
visibility: visible;
transform: rotateX(0deg) scale(1,1);
opacity: 1;
transition: transform 0.4s ease, opacity 0.4s ease;
}
HTML:
<nav>
<ul>
<li>
[Logo]
</li>
<li>
About
</li>
<li class="hover">
Services
<div class="services-list-container">
<ul>
<li>
Information
</li>
<li>
Technology
</li>
<li>
Training
</li>
<li>
Project Support
</li>
</ul>
</div>
</li>
<li>
News
</li>
<li>
Jobs
</li>
<li>
Contact
</li>
</ul>
</nav>
Please check if this is what you want. Submenu is hidden until the hover takes place.
* {
margin: 0;
padding: 0;
font-family: Montserrat;
}
li {
list-style: none;
}
a {
text-decoration: none;
}
nav {
background-color: white;
height: 60px;
display: flex;
justify-content: center;
align-items: center;
}
nav>ul>li {
display: inline-block;
position: relative;
height: 60px;
cursor: pointer;
}
nav a {
color: rgba(165, 175, 185, 1);
}
nav>ul>li>a {
padding: 0 20px;
line-height: 60px;
}
nav>ul>li:hover>a {
color: rgba(105, 115, 125, 1);
}
nav>ul>li:hover .services-list-container {
display: inline-block;
}
nav>ul>li:first-of-type {
margin-right: auto;
}
.services-list-container {
visibility: hidden;
z-index: -1;
position: absolute;
width: 200px;
top: 100%;
opacity: 0;
transition: opacity .4s ease;
}
.services-list-container ul {
background-color: white;
box-shadow: 0 6px 16px rgba(40, 40, 90, 0.15);
position: relative;
}
.services-list-container a {
padding: 20px;
display: block;
}
.services-list-container a:hover {
background-color: rgba(235, 240, 245, 1);
}
.hover:hover .services-list-container {
z-index: 0;
visibility: visible;
opacity: 1;
}
<nav>
<ul>
<li>
[Logo]
</li>
<li>
About
</li>
<li class="hover">
Services
<div class="services-list-container">
<ul>
<li>
Information
</li>
<li>
Technology
</li>
<li>
Training
</li>
<li>
Project Support
</li>
</ul>
</div>
</li>
<li>
News
</li>
<li>
Jobs
</li>
<li>
Contact
</li>
</ul>

How can I create a drop-down menu which hovers over background image?

I'm new to html/css and i've been working on this drop down menu: http://cssdeck.com/labs/he8ykb8n
First problem: I'm trying to make the drop-down menu hover over a background image/slideshow. For some reason i can't do that.
This is what I'm trying to achieve: http://bildeopplaster.no/3qi so the dropdown menu is hovering over the background image.
Second problem: Also if you can see on the demo above you only have "Men's wear" button. I tried to copy the code and just change the button name so all the buttons can be shown like on the nn the picture, but the code didn't align the new button next to the "men's wear" button. Is there any way i can fix so that i can get all the buttons next to each other with same hovering effect?
HTML code for the navbar:
<nav class="navigation">
<ul>
<li class="menubar">MEN'S WEAR
<ul>
<li class="dropdown">TOPWEAR
<ul>
<li>Jackets & Coats</li>
<li>Shirts</li>
<li>Overshirts</li>
<li>T-Shirts</li>
<li>Basic T-Shirts</li>
<li>Knitwear</li>
<li>Sweats</li>
</ul>
</li>
<li class="dropdown">BOTTOMWEAR
<ul>
<li>Jeans</li>
<li>Colour Jeans</li>
<li>Pants</li>
<li>Shorts</li>
</ul>
</li>
<li class="dropdown">FOOTWEAR
<ul>
<li>Boots</li>
<li>Sandals</li>
<li>Shoes</li>
<li>Snickers</li>
</ul>
</li>
<li class="dropdown">ACCESSORIES
<ul>
<li>Belts</li>
<li>Caps</li>
<li>Hats</li>
<li>Scarves</li>
<li>Gloves</li>
<li>Sunglasses</li>
<li>Watches</li>
<li>Jewelry</li>
</ul>
</li>
<li class="dropdown">SALE
<ul>
<li>Jackets & Coats</li>
<li>Shirts</li>
<li>Overshirts</li>
<li>T-Shirts</li>
<li>Basic T-Shirts</li>
<li>Knitwear</li>
<li>Sweats</li>
</ul>
</li>
</ul>
</li>
</ul>
<ul>
<li class="menubar">MEN'S WEAR
<ul>
<li class="dropdown">TOPWEAR
<ul>
<li>Jackets & Coats</li>
<li>Shirts</li>
<li>Overshirts</li>
<li>T-Shirts</li>
<li>Basic T-Shirts</li>
<li>Knitwear</li>
<li>Sweats</li>
</ul>
</li>
<li class="dropdown">BOTTOMWEAR
<ul>
<li>Jeans</li>
<li>Colour Jeans</li>
<li>Pants</li>
<li>Shorts</li>
</ul>
</li>
<li class="dropdown">FOOTWEAR
<ul>
<li>Boots</li>
<li>Sandals</li>
<li>Shoes</li>
<li>Snickers</li>
</ul>
</li>
<li class="dropdown">ACCESSORIES
<ul>
<li>Belts</li>
<li>Caps</li>
<li>Hats</li>
<li>Scarves</li>
<li>Gloves</li>
<li>Sunglasses</li>
<li>Watches</li>
<li>Jewelry</li>
</ul>
</li>
<li class="dropdown">SALE
<ul>
<li>Jackets & Coats</li>
<li>Shirts</li>
<li>Overshirts</li>
<li>T-Shirts</li>
<li>Basic T-Shirts</li>
<li>Knitwear</li>
<li>Sweats</li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
CSS code for the navigation bar:
.navigation {
position: relative;
background-color: #ddd;
width: 1024px;
height: 42px;
margin: 0 auto;
-webkit-font-smoothing:antialiased;
}
.navigation a {
-webkit-transition: all .25s ease;
-moz-transition: all .25s ease;
-ms-transition: all .25s ease;
-o-transition: all .25s ease;
transition: all .25s ease;
}
.menubar ul {
opacity: 0;
position: relative;
top: 0px;
visibility: hidden;
z-index: 1;
-webkit-transition: all .25s ease;
-moz-transition: all .25s ease;
-ms-transition: all .25s ease;
-o-transition: all .25s ease;
transition: all .25s ease;
}
.menubar {
position: relative;
list-style: none;
display: inline;
}
.menubar a {
text-decoration: none;
position: relative;
top: 12px;
right: 40px;
font-weight: bold;
padding: 12px 15px 11px 15px;
}
.menubar a:nth-child(1) {
color: #000;
list-style: none;
}
.menubar a:hover:nth-child(1) {
color: #fff;
background: #000;
}
.menubar:hover ul {
visibility: visible;
opacity: 1;
}
.menubar li{
background: transparent;
}
.dropdown:nth-child(1) {
float: left;
background: #000;
position: relative;
list-style: none;
top: 22px;
right: 80px;
padding-bottom: 96px;
padding-left: 40px;
padding-top: 1px;
margin-right: -20px;
}
.dropdown:nth-child(2) {
float: left;
background: #000;
position: relative;
list-style: none;
top: 22px;
right: 60px;
padding-bottom: 200px;
padding-left: 40px;
padding-top: 1px;
margin-right: -20px;
}
.dropdown:nth-child(3) {
float: left;
background: #000;
position: relative;
list-style: none;
top: 22px;
right: 40px;
padding-bottom: 200px;
padding-left: 40px;
padding-top: 1px;
margin-right: -20px;
}
.dropdown:nth-child(4) {
float: left;
background: #000;
position: relative;
list-style: none;
top: 22px;
right: 20px;
padding-bottom: 63px;
padding-left: 40px;
padding-top: 1px;
margin-right: -20px;
}
.dropdown:nth-child(5) {
float: left;
background: #000;
position: relative;
list-style: none;
top: 22px;
right: 20px;
left: 0px;
padding-bottom: 100px;
padding-left: 42px;
padding-right: 20px;
padding-top: 1px;
}
.dropdown a {
right: 10px;
position: relative;
top: 10px;
left: -40px;
font-weight: bold;
color: #888;
}
.dropdown a:hover {
text-decoration: underline;
color: #fff;
}
.dropdown a:nth-child(1) {
color: #cbcbcb;
}
.dropdown ul {
list-style: none;
display: inline;
position: relative;
padding: 15px;
}
.dropdown ul li {
position: relative;
padding: 8px;
top: 5px;
right: 5px;
font-size: 13.5px;
}
.dropdown ul li a {
font-weight: normal;
}
try this
.menubar:hover ul {
opacity: 0.5;
}
On a side note, always use display:none to hide and display:block to show elements. Visibility can create problems.

css position dropdown menu issue

I have a menu that is appearing behind the banner. I need to show it over the banner.
By removing the :
.ei-slider-large li{
position: absolute;
}
its solve the issue, but then the banner is not working.
Below are details of my implementation :
Menu:
<div id='cssmenu'>
<ul>
<li class='active'><a href='index.php'><span>Home</span></a></li>
<li class='has-sub'><a href='#'><span>About Us</span></a>
<ul>
<li><span>Our Story</span></li>
<li><span>Our Leadership Team</span></li>
<li><span>Testimonials</span></li>
</ul>
</li>
<li class='has-sub '><a href='#'><span>Our Services</span></a>
<ul>
<li><a href='geopolitical.php'><span>Geo-Political Risk Management</span></a></li>
<li><a href='security.php'><span>Security & Business Continuity</span></a></li>
<li><a href='business.php'><span>Business Resiliency</span></a></li>
<li><a href='integrity.php'><span>Integrity & Assurance</span></a></li>
</ul>
</li>
<li class='has-sub '><a href='#'><span>Insights</span></a>
<ul>
<li><a href='alerts_ads.php'><span>Alerts & Advisories</span></a></li>
<li><a href='research.php'><span>Research</span></a></li>
<li><a href='news_events.php'><span>News & Events</span></a></li>
</ul>
</li>
<li><a href='csr.php'><span>CSR</span></a></li>
<li class='has-sub '><a href='#'><span>Contact Us</span></a>
<ul>
<li><a href='our_office.php'><span>Our Offices</span></a></li>
</ul>
</li>
</ul>
</div>
menu css:
#cssmenu:after,
#cssmenu ul:after {
display: block;
clear: both;
}
#cssmenu a {
color: #333;
display: inline-block;
font-size: 15px;
font-weight:bold;
padding: 0 20px;
margin-left:10px;
margin-right:10px;
text-decoration: none;
border:1px solid #FFF;
}
#cssmenu a:hover {
position: relative;
top: 0;
}
#cssmenu ul {
list-style: none;
}
#cssmenu > ul {
width: 100%;
}
#cssmenu > ul > li {
float: left;
padding: 0 10px;
position: relative;
}
#cssmenu > ul > li.active a {
background: #FFF;
border-radius: 4px 4px 0 0;
-moz-border-radius: 4px 4px 0 0;
-webkit-border-radius: 4px 4px 0 0;
position: relative;
color:#569C17;
border:1px solid #CCC;
}
#cssmenu > ul > li.active a:hover {
background: #FFF;
border-radius: 4px 4px 0 0;
-moz-border-radius: 4px 4px 0 0;
-webkit-border-radius: 4px 4px 0 0;
position: relative;
color:#569C17;
}
#cssmenu > ul > li.has-sub-active > a {
background: #FFF;
border-radius: 4px 4px 0 0;
-moz-border-radius: 4px 4px 0 0;
-webkit-border-radius: 4px 4px 0 0;
position: relative;
display: block;
color:#569C17;
border:1px solid #CCC;
}
#cssmenu .has-sub-active:hover ul {
display: block;
}
#cssmenu .has-sub-active a {
display: block;
position: relative;
}
#cssmenu .has-sub-active a:after {
}
#cssmenu .has-sub-active ul {
background: #FFF;
display: none;
padding: 10px 0;
position: absolute;
left: 50%;
top: 41px;
margin-left: -70px;
width: 200px;
z-index: 1;
border-bottom:1px solid #CCC;
border-left:1px solid #CCC;
border-right:1px solid #CCC;
}
#cssmenu .has-sub-active ul li:hover > a {
background: #dddddd;
color: #569C17;
font-size:12px;
}
#cssmenu .has-sub-active ul a {
line-height: 100%;
padding: 8px 0;
font-size:12px;
color:#333;
}
#cssmenu > ul > li:hover > a {
background: #FFF;
border-radius: 4px 4px 0 0;
-moz-border-radius: 4px 4px 0 0;
-webkit-border-radius: 4px 4px 0 0;
position: relative;
color:#569C17;
border-top:1px solid #CCC;
border-left:1px solid #CCC;
border-right:1px solid #CCC;
}
#cssmenu > ul > li a {
line-height: 39px;
}
#cssmenu > ul > li a:hover {
}
#cssmenu .has-sub:hover ul {
display: block;
}
#cssmenu .has-sub a {
display: block;
position: relative;
}
#cssmenu .has-sub a:after {
}
#cssmenu .has-sub ul {
background: #FFF;
display: none;
padding: 10px 0;
position: absolute;
left: 50%;
top: 41px;
margin-left: -70px;
width: 200px;
z-index: 1;
border-bottom:1px solid #CCC;
border-left:1px solid #CCC;
border-right:1px solid #CCC;
}
#cssmenu .has-sub ul li:hover > a {
background: #dddddd;
color: #569C17;
font-size:12px;
}
#cssmenu .has-sub ul a {
line-height: 100%;
padding: 8px 0;
font-size:12px;
color:#333;
}
banner:
<div id="ei-slider" class="ei-slider">
<ul class="ei-slider-large">
<li> <img src="images/large/1.jpg" alt="image01" />
<div class="ei-title">
<h3>Geo-Political Risk Management</h3>
</div>
</li>
<li> <img src="images/large/2.jpg" alt="image02" />
<div class="ei-title">
<h3>Security & Business Continuity</h3>
</div>
</li>
<li> <img src="images/large/3.jpg" alt="image03"/>
<div class="ei-title">
<h3>Business Resiliency</h3>
</div>
</li>
<li> <img src="images/large/4.jpg" alt="image04"/>
<div class="ei-title">
<h3>Integrity & Assurance</h3>
</div>
</li>
</ul><!-- ei-slider-large -->
<ul class="ei-slider-thumbs">
<li class="ei-slider-element">Current</li>
<li>Slide 1<img src="images/thumbs/1.jpg" alt="thumb01" /></li>
<li>Slide 2<img src="images/thumbs/2.jpg" alt="thumb02" /></li>
<li>Slide 3<img src="images/thumbs/3.jpg" alt="thumb03" /></li>
<li>Slide 4<img src="images/thumbs/4.jpg" alt="thumb04" /></li>
</ul>
<!-- ei-slider-thumbs -->
</div><!-- ei-slider -->
banner css:
.ei-slider{
position: relative;
width: 100%;
max-width: 1920px;
height: 400px;
margin: 0 auto;
}
.ei-slider-loading{
width: 100%;
height: 100%;
position: absolute;
top: 0px;
left: 0px;
z-index:999;
color: #fff;
text-align: center;
line-height: 400px;
}
.ei-slider-large{
height: 100%;
width: 100%;
position:relative;
overflow: hidden;
}
.ei-slider-large li{
position: absolute;
top: 0px;
left: 0px;
overflow: hidden;
height: 100%;
width: 100%;
}
.ei-slider-large li img{
width: 100%;
}
.ei-title{
position: absolute;
right: 50%;
margin-right: 13%;
top: 30%;
}
.ei-title h2, .ei-title h3{
text-align: right;
}
.ei-title h2{
font-size: 40px;
line-height: 50px;
font-family: 'Playfair Display', serif;
font-style: italic;
color: #b5b5b5;
}
.ei-title h3{
font-size: 30px;
line-height: 70px;
font-family: 'Open Sans Condensed', sans-serif;
text-transform: uppercase;
color: #000;
}
.ei-slider-thumbs{
height: 13px;
margin: 0 auto;
position: relative;
}
.ei-slider-thumbs li{
position: relative;
float: left;
height: 100%;
}
.ei-slider-thumbs li.ei-slider-element{
top: 0px;
left: 0px;
position: absolute;
height: 100%;
z-index: 10;
text-indent: -9000px;
background: #000;
background: rgba(0,0,0,0.9);
}
.ei-slider-thumbs li a{
display: block;
text-indent: -9000px;
background: #666 ;
width: 100%;
height: 100%;
cursor: pointer;
-webkit-box-shadow:
0px 1px 1px 0px rgba(0,0,0,0.3),
0px 1px 0px 1px rgba(255,255,255,0.5);
-moz-box-shadow:
0px 1px 1px 0px rgba(0,0,0,0.3),
0px 1px 0px 1px rgba(255,255,255,0.5);
box-shadow:
0px 1px 1px 0px rgba(0,0,0,0.3),
0px 1px 0px 1px rgba(255,255,255,0.5);
-webkit-transition: background 0.2s ease;
-moz-transition: background 0.2s ease;
-o-transition: background 0.2s ease;
-ms-transition: background 0.2s ease;
transition: background 0.2s ease;
}
.ei-slider-thumbs li a:hover{
background-color: #f0f0f0;
}
.ei-slider-thumbs li img{
position: absolute;
bottom: 50px;
opacity: 0;
z-index: 999;
max-width: 100%;
-webkit-transition: all 0.4s ease;
-moz-transition: all 0.4s ease;
-o-transition: all 0.4s ease;
-ms-transition: all 0.4s ease;
transition: all 0.4s ease;
-webkit-box-reflect:
below 0px -webkit-gradient(
linear,
left top,
left bottom,
from(transparent),
color-stop(50%, transparent),
to(rgba(255,255,255,0.3))
);
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
}
.ei-slider-thumbs li:hover img{
opacity: 1;
bottom: 13px;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
}
The problem is in your z-index.
As you can see, you've given your #cssmenu .has-sub ul { z-index:1; }
And your .ei-slider-thumbs li img { z-index:999; }
Try setting the z-index of your menu to 9999 or lowering/removing the z-index of your slider.