Display list items horizontally on hover - html

Here I have a side navigation bar which expands on hover, but I have been trying to get the social icons to display horizontally instead of vertically on hover.
I couldn't find anything related to this subject (unless I overlooked something). Can I get some help please?
.navmenu {
top: 5%;
height: 90%;
width: 50px;
background-color: rgba(51, 51, 51, 0.80);
position: fixed;
border-top: 5px solid black;
border-bottom: 5px solid black;
transition: 0.5s ease;
z-index: 100;
}
.navextend {
border-left: 40px solid rgba(51, 51, 51, 0.80);
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
height: 79.5%;
left: 50px;
position: fixed;
transition: 0.5s ease;
}
#primary_nav_wrap {
z-index: 100;
}
#primary_nav_wrap ul {
list-style: none;
position: absolute;
text-align: left;
margin-top: 40px;
z-index: 100;
left: -15px;
transition: 0.5s ease;
}
#primary_nav_wrap ul li {
padding-right: 0px;
}
.current {
color: crimson;
font-size: 120%;
}
#primary_nav_wrap ul li {
padding: 15px 30px;
display: block;
text-align: left;
}
#primary_nav_wrap ul a {
color: rgba(255, 255, 255, 0.80);
}
#primary_nav_wrap ul li:hover>a {
opacity: 0.5;
}
.navmenu img {
height: 30px
}
.navmenu img:hover {
opacity: 0.5;
}
.social {
bottom: 20px;
margin-left: 7px;
transition: 0.5s ease;
}
.social li {
text-align: center;
}
.navmenu:hover {
height: 98.5%;
top: 0px;
width: 120px;
background-color: rgba(38, 38, 38, 0.80);
}
.navmenu:hover .navextend {
left: 120px;
border-left: 70px solid rgba(38, 38, 38, 0.80);
border-top: 50px solid transparent;
border-bottom: 50px solid transparent;
height: 81.3%;
}
.navmenu:hover .social>img {
display: inline;
}
.navmenu:hover .menu {
margin-left: 40px;
font-size: 120%;
}
.navmenu:hover>#primary_nav_wrap ul li {
text-align: center;
}
<div class="navmenu">
<nav id="primary_nav_wrap">
<ul class="menu">
<li class="current">Home</li>
<a href="#">
<li class="link">Services</li>
</a>
<li>About<br> us</li>
<li>Contact</li>
<li>EN</li>
</ul>
<ul class="social">
<li><img src="Images/_Gmail.svg.png"> </li>
<li><img src="Images/fb-art.png"></li>
<li><img src="Images/twitterlogo_1x.png"></li>
</ul>
<div class="navextend">
</div>
</nav>
</div>

Just apply these two lines in your CSS:
.navmenu:hover #primary_nav_wrap .social { white-space: nowrap; }
.navmenu:hover #primary_nav_wrap .social li { display: inline-block; }
/* spaces between icons: */
.navmenu:hover #primary_nav_wrap .social li { padding: 5px 5px; }
.navmenu {
top: 5%;
height: 90%;
width: 50px;
background-color: rgba(51, 51, 51, 0.80);
position: fixed;
border-top: 5px solid black;
border-bottom: 5px solid black;
transition: 0.5s ease;
z-index: 100;
}
.navextend {
border-left: 40px solid rgba(51, 51, 51, 0.80);
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
height: 79.5%;
left: 50px;
position: fixed;
transition: 0.5s ease;
}
#primary_nav_wrap {
z-index: 100;
}
#primary_nav_wrap ul {
list-style: none;
position: absolute;
text-align: left;
margin-top: 40px;
z-index: 100;
left: -15px;
transition: 0.5s ease;
}
#primary_nav_wrap ul li {
padding-right: 0px;
}
.current {
color: crimson;
font-size: 120%;
}
#primary_nav_wrap ul li {
padding: 15px 30px;
display: block;
text-align: left;
}
#primary_nav_wrap ul a {
color: rgba(255, 255, 255, 0.80);
}
#primary_nav_wrap ul li:hover>a {
opacity: 0.5;
}
.navmenu img {
height: 30px
}
.navmenu img:hover {
opacity: 0.5;
}
.social {
bottom: 20px;
margin-left: 7px;
transition: 0.5s ease;
}
.social li {
text-align: center;
}
.navmenu:hover {
height: 98.5%;
top: 0px;
width: 120px;
background-color: rgba(38, 38, 38, 0.80);
}
.navmenu:hover .navextend {
left: 120px;
border-left: 70px solid rgba(38, 38, 38, 0.80);
border-top: 50px solid transparent;
border-bottom: 50px solid transparent;
height: 81.3%;
}
.navmenu:hover .social>img {
display: inline;
}
.navmenu:hover .menu {
margin-left: 40px;
font-size: 120%;
}
.navmenu:hover>#primary_nav_wrap ul li {
text-align: center;
}
.navmenu:hover #primary_nav_wrap .social { white-space: nowrap; }
.navmenu:hover #primary_nav_wrap .social li { display: inline-block; }
.navmenu:hover #primary_nav_wrap .social li { padding: 5px 5px; }
<div class="navmenu">
<nav id="primary_nav_wrap">
<ul class="menu">
<li class="current">Home</li>
<a href="#">
<li class="link">Services</li>
</a>
<li>About<br> us</li>
<li>Contact</li>
<li>EN</li>
</ul>
<ul class="social">
<li><img src="Images/_Gmail.svg.png"> </li>
<li><img src="Images/fb-art.png"></li>
<li><img src="Images/twitterlogo_1x.png"></li>
</ul>
<div class="navextend">
</div>
</nav>
</div>

Related

div class doesn't seem to work

I have to build a website for school and I am having trouble with a div class.
I wanted a new div for blog posts but it doesn't seem to work. If you take a look at my css you see that I changed the height but the text didn't move down. I called the div class 'first' and wrote some text to see where it would end up.
body {}
/*---- website---*/
#header {
position: relative;
top: 10px;
left: 0px;
font-size: 25px;
font-family: Lucida Console;
color: white;
background-color: #98AFC7;
width: 100%;
height: 50px;
padding: 20px 0px 10px 0px;
}
/*----lost een bug op die li en ul laat verdwijnen----*/
.clearfix:after {
display: block;
clear: both;
}
/*----- Menu -----*/
.menu-wrap {
position: relative;
left: 120px;
top: 0px;
width: 100%;
box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.2);
}
.menu {
width: 1000px;
margin: 30px auto;
}
.menu li {
margin: 0px;
list-style: none;
font-family: 'Ek Mukta';
}
.menu a {
transition: all linear 0.15s;
color: #D7D7D7;
}
.menu li:hover>a,
.menu .current-item>a {
text-decoration: none;
color: #fff;
}
.menu .arrow {
font-size: 11px;
line-height: 0%;
}
/*----- basis menu -----*/
.menu>ul>li {
float: left;
display: inline-block;
position: relative;
font-size: 19px;
}
.menu>ul>li>a {
padding: 10px 40px;
display: inline-block;
text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.4);
}
.menu>ul>li:hover>a,
.menu>ul>.current-item>a {
background: #70879F;
}
/*-----2e menu-----*/
.menu li:hover .sub-menu {
z-index: 1;
opacity: 1;
}
.sub-menu {
width: 160%;
padding: 5px 0px;
position: absolute;
top: 100%;
left: 0px;
opacity: 0;
transition: opacity linear 0.15s;
box-shadow: 0px 2px 3px rgba(0, 0, 0, 0.2);
background: #70879F;
}
.sub-menu li {
display: block;
font-size: 16px;
}
.sub-menu li a {
padding: 10px 30px;
display: block;
}
.sub-menu li a:hover,
.sub-menu .current-item a {
background: #98AFC7;
}
.first {
margin: 600px 0px 0px 0px;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="Home.css">
</head>
<body>
<div class="first">
tekst-tekst
</div>
<div id="header">
<center><big>No strings attached</big></center>
</div>
<!--menu-->
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li>Home</li>
<li class="current-item">Blog</li>
<li>
Webshop <span class="arrow">▼</span>
<ul class="sub-menu">
<li>Gitaren</li>
<li>Electronica</li>
<li>Overig</li>
<li>Sale</li>
</ul>
</li>
<li>Contact</li>
<li>Over mij</li>
</ul>
</nav>
</div>
</body>
</html>

How to make this box to a triangle in css [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
please check out this code pen link
want to make the square beside home to triangle upside down. when i hover - its working correctly
https://codepen.io/shaswat/pen/gXLBwo
please help me to make that square to triangle .creating a navigation bar
after I hover its working correctly by transforming to upside
/* Menu CSS */#cssmenu,
#cssmenu > ul {
background: black;
padding-bottom: 3px;
}
#cssmenu:before,
#cssmenu:after,
#cssmenu > ul:before,
#cssmenu > ul:after {
content: "";
display: table;
box-sizing: border-box;
}
#cssmenu:after,
#cssmenu > ul:after {
clear: both;
}
#cssmenu {
width: auto;
zoom: 1;
}
#cssmenu > ul {
background: blue;
margin: 0;
padding: 0;
position: relative;
}
#cssmenu > ul li {
margin: 0;
padding: 0;
list-style: none;
}
#cssmenu > ul > li {
float: left;
position: relative;
}
#cssmenu > ul > li > a {
padding: 15px 25px;
display: block;
color: white;
font-size: 13px;
text-decoration: none;
text-transform: uppercase;
text-shadow: 0 -1px 0 #0d0d0d;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.7);
}
#cssmenu > ul > li:hover > a {
background: red;
text-shadow: 0 -1px 0 #97321f;
text-shadow: 0 -1px 0 rgba(122, 42, 26, 0.64);
}
#cssmenu > ul > li.active > a,
#cssmenu > ul > li > a.active {
background: grey;
}
/* Childs */
#cssmenu > ul ul {
opacity: 0;
visibility: hidden;
position: absolute;
top: 50px;
background: green;
margin: 0;
padding: 0;
z-index: -1;
}
#cssmenu > ul li:hover ul {
opacity: 1;
visibility: visible;
margin: 0;
color: #000;
z-index: 2;
top: 50px;
left: 0;
}
#cssmenu > ul ul:before {
content: "";
position: absolute;
top: -10px;
width: 100%;
height: 18px;
background: transparent;
}
#cssmenu > ul ul li {
list-style: none;
padding: 0;
margin: 0;
width: 100%;
}
#cssmenu > ul ul li a {
padding: 15px 26px;
display: block;
color: white;
font-size: 14px;
text-decoration: none;
width: 150px;
border-left: 4px solid transparent;
-webkit-transition: all 0.50s ease-in-out;
-moz-transition: all 0.50s ease-in-out;
-ms-transition: all 0.50s ease-in-out;
transition: all 0.50s ease-in-out;
}
#cssmenu > ul ul li a:hover {
border-left: 10px solid #d64e34;
background: grey;
}
#cssmenu > ul ul li a:active {
background: green;
}
#cssmenu li a:first-child:nth-last-child(2):before {
content:"";
position: absolute;
height: 0;
width: 0;
border: 8px solid orange;
top: 40%;
right: 5px;
}
#cssmenu li:hover > a:first-child:nth-last-child(2):before {
border: 8px solid transparent;
border-bottom-color: orange;
margin-top: -5px;
}
<div id='cssmenu'>
<ul>
<li><a href='#'>Home</a>
<ul>
<li><a href='#'>Product 1</a></li>
<li><a href='#'>Product 2</a></li>
<li><a href='#'>Product 3</a></li>
</ul>
</li>
<li><a class='active' href='#'>Products</a></li>
<li><a href='#'>About</a></li>
<li><a href='#'>Contact</a></li>
</ul>
</div>
On the line 119 replace orange with transparent. And add border-top-color: orange;. If you make border-bottom-color instead of border-top-color arrow will be reversed.
border: 8px solid transparent;
border-top-color: orange;
Change the code of #cssmenu li a:first-child:nth-last-child(2):before like this :
#cssmenu li a:first-child:nth-last-child(2):before {
content: "";
position: absolute;
height: 0;
width: 0;
border: 8px solid transparent;
border-top-color: orange;
top: 40%;
right: 5px;
}
the full code :
/* Menu CSS */
#cssmenu,
#cssmenu>ul {
background: black;
padding-bottom: 3px;
}
#cssmenu:before,
#cssmenu:after,
#cssmenu>ul:before,
#cssmenu>ul:after {
content: "";
display: table;
box-sizing: border-box;
}
#cssmenu:after,
#cssmenu>ul:after {
clear: both;
}
#cssmenu {
width: auto;
zoom: 1;
}
#cssmenu>ul {
background: blue;
margin: 0;
padding: 0;
position: relative;
}
#cssmenu>ul li {
margin: 0;
padding: 0;
list-style: none;
}
#cssmenu>ul>li {
float: left;
position: relative;
}
#cssmenu>ul>li>a {
padding: 15px 25px;
display: block;
color: white;
font-size: 13px;
text-decoration: none;
text-transform: uppercase;
text-shadow: 0 -1px 0 #0d0d0d;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.7);
}
#cssmenu>ul>li:hover>a {
background: red;
text-shadow: 0 -1px 0 #97321f;
text-shadow: 0 -1px 0 rgba(122, 42, 26, 0.64);
}
#cssmenu>ul>li.active>a,
#cssmenu>ul>li>a.active {
background: grey;
}
/* Childs */
#cssmenu>ul ul {
opacity: 0;
visibility: hidden;
position: absolute;
top: 50px;
background: green;
margin: 0;
padding: 0;
z-index: -1;
}
#cssmenu>ul li:hover ul {
opacity: 1;
visibility: visible;
margin: 0;
color: #000;
z-index: 2;
top: 50px;
left: 0;
}
#cssmenu>ul ul:before {
content: "";
position: absolute;
top: -10px;
width: 100%;
height: 18px;
background: transparent;
}
#cssmenu>ul ul li {
list-style: none;
padding: 0;
margin: 0;
width: 100%;
}
#cssmenu>ul ul li a {
padding: 15px 26px;
display: block;
color: white;
font-size: 14px;
text-decoration: none;
width: 150px;
border-left: 4px solid transparent;
-webkit-transition: all 0.50s ease-in-out;
-moz-transition: all 0.50s ease-in-out;
-ms-transition: all 0.50s ease-in-out;
transition: all 0.50s ease-in-out;
}
#cssmenu>ul ul li a:hover {
border-left: 10px solid #d64e34;
background: grey;
}
#cssmenu>ul ul li a:active {
background: green;
}
#cssmenu li a:first-child:nth-last-child(2):before {
content: "";
position: absolute;
height: 0;
width: 0;
border: 8px solid transparent;
border-top-color: orange;
top: 40%;
right: 5px;
}
#cssmenu li:hover>a:first-child:nth-last-child(2):before {
border: 8px solid transparent;
border-bottom-color: orange;
margin-top: -5px;
}
<div id='cssmenu'>
<ul>
<li><a href='#'>Home</a>
<ul>
<li><a href='#'>Product 1</a></li>
<li><a href='#'>Product 2</a></li>
<li><a href='#'>Product 3</a></li>
</ul>
</li>
<li><a class='active' href='#'>Products</a></li>
<li><a href='#'>About</a></li>
<li><a href='#'>Contact</a></li>
</ul>
</div>
Instead of having #cssmenu li a:first-child:nth-last-child(2):before have border: 8px solid orange; replace it with border: 8px solid transparent; and border-top-color: orange;. This will give you a down arrow and when you hover it will turn into an up arrow.
As an alternative, you could use a font. Replace the last two rules with this:
#cssmenu>ul>li>a::after {
content: "⏷";
position: absolute;
line-height: .5;
font-size: 24px;
transform: rotate(0deg) translateY(0);
margin-left: 5px;
color:orange;
transition:.5s ease;
}
#cssmenu>ul>li:hover>a::after {
transform:rotate(180deg) translate(5px,-5px);
transform-origin:center;
transition:.5s ease;
}
Demo
/* Menu CSS */
#cssmenu,
#cssmenu>ul {
background: black;
padding-bottom: 3px;
}
#cssmenu:before,
#cssmenu:after,
#cssmenu>ul:before,
#cssmenu>ul:after {
content: "";
display: table;
box-sizing: border-box;
}
#cssmenu:after,
#cssmenu>ul:after {
clear: both;
}
#cssmenu {
width: auto;
zoom: 1;
}
#cssmenu>ul {
background: blue;
margin: 0;
padding: 0;
position: relative;
}
#cssmenu>ul li {
margin: 0;
padding: 0;
list-style: none;
}
#cssmenu>ul>li {
float: left;
position: relative;
}
#cssmenu>ul>li>a {
padding: 15px 25px;
display: block;
color: white;
font-size: 13px;
text-decoration: none;
text-transform: uppercase;
text-shadow: 0 -1px 0 #0d0d0d;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.7);
}
#cssmenu>ul>li:hover>a {
background: red;
text-shadow: 0 -1px 0 #97321f;
text-shadow: 0 -1px 0 rgba(122, 42, 26, 0.64);
}
#cssmenu>ul>li.active>a,
#cssmenu>ul>li>a.active {
background: grey;
}
/* Childs */
#cssmenu>ul ul {
opacity: 0;
visibility: hidden;
position: absolute;
top: 50px;
background: green;
margin: 0;
padding: 0;
z-index: -1;
}
#cssmenu>ul li:hover ul {
opacity: 1;
visibility: visible;
margin: 0;
color: #000;
z-index: 2;
top: 50px;
left: 0;
}
#cssmenu>ul ul:before {
content: "";
position: absolute;
top: -10px;
width: 100%;
height: 18px;
background: transparent;
}
#cssmenu>ul ul li {
list-style: none;
padding: 0;
margin: 0;
width: 100%;
}
#cssmenu>ul ul li a {
padding: 15px 26px;
display: block;
color: white;
font-size: 14px;
text-decoration: none;
width: 150px;
border-left: 4px solid transparent;
-webkit-transition: all 0.50s ease-in-out;
-moz-transition: all 0.50s ease-in-out;
-ms-transition: all 0.50s ease-in-out;
transition: all 0.50s ease-in-out;
}
#cssmenu>ul ul li a:hover {
border-left: 10px solid #d64e34;
background: grey;
}
#cssmenu>ul ul li a:active {
background: green;
}
#cssmenu>ul>li:first-of-type>a::after {
content: "⏷";
position: absolute;
line-height: .5;
font-size: 24px;
transform: rotate(0deg) translate(-5px,0);
margin-left: 5px;
color:orange;
transition:.5s ease;
}
#cssmenu>ul>li:first-of-type:hover>a::after {
transform:rotate(180deg) translate(5px,-5px);
transform-origin:center;
transition:.5s ease;
}
<div id='cssmenu'>
<ul>
<li><a href='#'>Home</a>
<ul>
<li><a href='#'>Product 1</a></li>
<li><a href='#'>Product 2</a></li>
<li><a href='#'>Product 3</a></li>
</ul>
</li>
<li><a class='active' href='#'>Products</a>
</li>
<li><a href='#'>About</a>
</li>
<li><a href='#'>Contact</a></li>
</ul>
</div>
just change this styles
#cssmenu li a:first-child:nth-last-child(2):before {
content:"";
position: absolute;
height:0;
width: 0;
border-top: 8px solid orange;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
top: 40% ;
right:5px;
}

I can't dropdown the submenu under its parent menus

It's the HTML of my code. I created navigation menubar with submenu in dropdown option but my submenu is not dropping down under the parent menu "dropdown" is parent menu.
.nav-wrap{
background:white;
width:100%;
height:50px;
position: relative;
top:-13px;
overflow:visible;
}
#example-one {
margin: 0 auto;
list-style: none;
position: relative;
width: 100%;
}
#example-one li {
display: inline-block;
font-family: 'Montserrat', sans-serif;
}
#example-one a {
color: #000;
font-weight:bold;
font-size: 14px;
float: left;
padding: 15px 15px;
text-decoration: none;
left:350px;
position:relative;
color:#000;
}
#example-one a:after {
color: #333;
content: '';
position: absolute;
width: 0; height: 3px;
display: block;
margin-top: 2px;
right: 0;
background: #000;
-webkit-transition-property: left, right;
transition-property: left, right;
transition: width 1s ease;
-webkit-transition: width 1s ease;
}
#example-one a:hover:after{
width: 100%;
left: 0;
background: #000;
}
.dropbtn {
color: white;
font-size: 16px;
border: none;
cursor: pointer;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
min-width: 160px;
box-shadow: 10px 10px 10px 10px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {background-color: #f1f1f1}
.dropdown:hover .dropdown-content
{
display: block;
}
<div class="nav-wrap">
<ul class="group" id="example-one">
<li>Home</li>
<li>
<div class="dropdown">
<a class="dropbtn">Dropdown</a>
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div></li>
<li>Offers</li>
<li>Group Sales</li>
<li>Reviews</li>
</ul></div>
Here is the CSS:
.nav-wrap{
background:white;
width:100%;
height:50px;
position: relative;
top:-13px;
overflow:visible;
}
#example-one {
margin: 0 auto;
list-style: none;
position: relative;
width: 100%;
}
#example-one li {
display: inline-block;
font-family: 'Montserrat', sans-serif;
}
#example-one a {
color: #000;
font-weight:bold;
font-size: 14px;
float: left;
padding: 15px 15px;
text-decoration: none;
left:350px;
position:relative;
color:#000;
}
#example-one a:after {
color: #333;
content: '';
position: absolute;
width: 0; height: 3px;
display: block;
margin-top: 2px;
right: 0;
background: #000;
-webkit-transition-property: left, right;
transition-property: left, right;
transition: width 1s ease;
-webkit-transition: width 1s ease;
}
#example-one a:hover:after{
width: 100%;
left: 0;
background: #000;
}
.dropbtn {
color: white;
font-size: 16px;
border: none;
cursor: pointer;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
min-width: 160px;
box-shadow: 10px 10px 10px 10px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {background-color: #f1f1f1}
.dropdown:hover .dropdown-content
{
display: block;
}
.nav-wrap {
background: white;
width: 100%;
}
#example-one {
text-align: right;
}
#example-one li {
text-align: left;
position: relative;
display: inline-block;
font-family: 'Montserrat', sans-serif;
}
#example-one a {
color: #000;
font-weight: bold;
font-size: 14px;
padding: 15px 15px;
text-decoration: none;
position: relative;
color: #000;
}
#example-one a:after {
color: #333;
content: '';
position: absolute;
width: 0;
height: 3px;
display: block;
margin-top: 2px;
right: 0;
background: #000;
-webkit-transition-property: left, right;
transition-property: left, right;
transition: width 1s ease;
-webkit-transition: width 1s ease;
}
#example-one a:hover:after {
width: 100%;
left: 0;
background: #000;
}
.dropdown-content {
display: none;
position: absolute;
top: 100%;
left: 0;
min-width: 160px;
box-shadow: 10px 10px 10px 10px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
text-decoration: none;
display: block;
}
#example-one li li {
display: block;
}
#example-one li:hover>ul {
display: block;
}
<div class="nav-wrap">
<ul class="group" id="example-one">
<li>Home</li>
<li><a class="dropbtn">Dropdown</a>
<ul class="dropdown-content">
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
</ul>
</li>
<li>Offers</li>
<li>Group Sales</li>
<li>Reviews</li>
</ul>
</div>
I've updated your CSS code and HTML as well. Your structure is over complicated and css with id does not reuseable for other dropdown menu.
.nav {
display: inline-block;
text-align: left;
}
.nav,
.dropdown {
padding: 0;
margin: 0;
list-style-type: none;
}
.nav > li {
float: left;
position: relative;
}
.nav li > a {
display: block;
position: relative;
padding: 10px 25px;
color: #000;
font: bold 14px sans-serif;
text-decoration: none;
}
.nav .dropdown {
display: none;
position: absolute;
top: 100%;
background-color: #fff;
box-shadow: 10px 10px 10px 10px rgba(0, 0, 0, .2);
min-width: 160px;
}
.nav .dropdown .dropdown {
top: 0;
left: 100%;
}
.nav .dropdown > li {
position: relative;
}
.nav li:hover > .dropdown {
display: block;
}
.nav .dropdown a:hover {
background-color: #f1f1f1;
}
.nav a::after {
content: '';
position: absolute;
right: 0;
bottom: 0;
width: 0;
height: 3px;
background: #000;
transition-property: left, right;
transition: width 1s ease;
}
.nav a:hover::after {
width: 100%;
left: 0;
background: #000;
}
<div style="text-align: center">
<ul class="nav">
<li>Home</li>
<li>
Dropdown
<ul class="dropdown">
<li>Link 1</li>
<li>
Link 2
<ul class="dropdown">
<li>Link 2.1</li>
<li>Link 2.2</li>
<li>Link 2.3</li>
</ul>
</li>
<li>Link 3</li>
</ul>
</li>
<li>Offers</li>
<li>Group Sales</li>
<li>Reviews</li>
</ul>
</div>

Navigation menu can't hide/show (Responsive Design)

Here is the coding what I have provided this one. This is for responsive design. When I click the logo, it didn't want to hide or show.
.toggle-nav {
display: none;
}
.menu {
float: right;
}
.menu ul {
display: inline-block;
}
.menu li {
float: left;
list-style: none;
font-size: 17px;
text-align: right;
}
.menuLink a {
font-size: 20px;
color: #FFF;
margin: 20px;
padding: 10px;
text-decoration: none;
float: left;
font-family: 'alegreya_sansregular';
cursor: pointer;
}
.menuLink a:hover,
.menu .current-item a {
border-bottom: 4px double #FFF;
}
.fixedPosition {
position: fixed !important;
top: 0;
left: 0;
}
#media only screen and (max-width: 820px) {
.menu {
position: relative;
display: inline-block;
}
.menu ul.active {
display: none;
}
.menu ul {
width: 100%;
position: absolute;
top: 90%;
left: -55px;
padding: 10px 18px;
box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.15);
border-radius: 3px;
background: #cecece;
}
.menu ul:after {
width: 0px;
height: 0px;
position: absolute;
top: 0%;
left: 87px;
content: '';
transform: translate(0%, -100%);
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-bottom: 7px solid #cecece;
}
.menu li {
margin: 5px 0px;
float: none;
display: inline-block;
}
.menuLink a {
display: block;
font-size: 15px;
margin: 10px 0;
padding: 5px 0;
float: none;
}
.menuLink a:hover,
.menu .current-item a {
border-bottom: none;
color: #666;
}
.toggle-nav {
padding: 20px;
float: left;
display: inline-block;
box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.15);
border-radius: 3px;
background: #cecece;
color: #777;
font-size: 20px;
transition: color linear 0.15s;
}
a.toggle-nav {
padding: 10px;
margin: 20px;
}
.toggle-nav:hover,
.toggle-nav.active {
color: #C3c3c3;
border-bottom: none;
position: relative;
}
}
<nav class="menu">
<ul class="menuLink">
<li> <a class="link-nav" data-scroll-nav="0"> HOME </a>
</li>
<li> WORKS
</li>
<li> <a data-scroll-nav="2"> ABOUT </a>
</li>
<li> <a data-scroll-nav="3"> CONTACT </a>
</li>
</ul>
<a class="toggle-nav" href="#">☰</a>
</nav>
Here is JSFIDDLE.
Before I click, the menu is staying there and doesn't want to hide. What I want is the menu has to hide at first before I click the logo. And also the menu can hide back after click the logo when it's showing. Any idea?
just use this jquery
$('.toggle-nav').click(function(){
$(this).parent().find('.menuLink').toggle();
});
FIDDLE
Here is my example with expanding and animated menues.
https://jsfiddle.net/9bn5t0kj/8/
$('.menu-header').on('click', function() {
$(this).next().toggleClass('menu-item-open');
$('.menu-item').not($(this).next()).removeClass('menu-item-open');
});
$(document).on('click', function(e) {
var clickedItem = $(e.target);
if (clickedItem.is($('.menu-header')) || clickedItem.is($('.menu-item'))) {
console.log(clickedItem);
return;
}
$('.menu-item').removeClass('menu-item-open');
});
.menu-item-container {
float: left;
}
.menu-header {
-webkit-user-select: none;
cursor: pointer;
}
.menu-item {
height: 0;
overflow: hidden;
-webkit-transition: height .25s;
}
.menu-item-open {
height: 200px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="menu">
<div class="menu-item-container">
<div class="menu-header">Open 1</div>
<div class="menu-item">
Hej hopp!<br>
Hej hopp!<br>
Hej hopp!<br>
Hej hopp!<br>
Hej hopp!<br>
</div>
</div>
<div class="menu-item-container">
<div class="menu-header">Open 2</div>
<div class="menu-item">
Hej hopp 2!<br>
Hej hopp 2!<br>
Hej hopp 2!<br>
Hej hopp 2!<br>
Hej hopp 2!<br>
</div>
</div>
You can hide it by default with jQuery .hide() and show it when .toggle-nav is clicked. it's pretty simple.
$(document).ready(function() {
$('.menuLink').hide();
$('.toggle-nav').click(function() {
$('.menuLink').toggle();
});
});
.toggle-nav {
display: none;
}
.menu {
float: right;
}
.menu ul {
display: inline-block;
}
.menu li {
float: left;
list-style: none;
font-size: 17px;
text-align: right;
}
.menuLink a {
font-size: 20px;
color: #FFF;
margin: 20px;
padding: 10px;
text-decoration: none;
float: left;
font-family: 'alegreya_sansregular';
cursor: pointer;
}
.menuLink a:hover,
.menu .current-item a {
border-bottom: 4px double #FFF;
}
.fixedPosition {
position: fixed !important;
top: 0;
left: 0;
}
#media only screen and (max-width: 820px) {
.menu {
position: relative;
display: inline-block;
}
.menu ul.active {
display: none;
}
.menu ul {
width: 100%;
position: absolute;
top: 90%;
left: -55px;
padding: 10px 18px;
box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.15);
border-radius: 3px;
background: #cecece;
}
.menu ul:after {
width: 0px;
height: 0px;
position: absolute;
top: 0%;
left: 87px;
content: '';
transform: translate(0%, -100%);
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-bottom: 7px solid #cecece;
}
.menu li {
margin: 5px 0px;
float: none;
display: inline-block;
}
.menuLink a {
display: block;
font-size: 15px;
margin: 10px 0;
padding: 5px 0;
float: none;
}
.menuLink a:hover,
.menu .current-item a {
border-bottom: none;
color: #666;
}
.toggle-nav {
padding: 20px;
float: left;
display: inline-block;
box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.15);
border-radius: 3px;
background: #cecece;
color: #777;
font-size: 20px;
transition: color linear 0.15s;
}
a.toggle-nav {
padding: 10px;
margin: 20px;
}
.toggle-nav:hover,
.toggle-nav.active {
color: #C3c3c3;
border-bottom: none;
position: relative;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<nav class="menu">
<ul class="menuLink">
<li> <a class="link-nav" data-scroll-nav="0"> HOME </a>
</li>
<li> WORKS
</li>
<li> <a data-scroll-nav="2"> ABOUT </a>
</li>
<li> <a data-scroll-nav="3"> CONTACT </a>
</li>
</ul>
<a class="toggle-nav" href="#">☰</a>
</nav>

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.