css navigation sub menu not showing right - css

Hello i have the following live example http://jsfiddle.net/vfubN/4/ where you can see a navigation in action if you check out docs you will see that the submenu isn't working right. Can someone help me out fixing it ? Seems that i can't see the solution even if it's in front of my eyes.
HTML
<header role="banner">
<div class="navbar fixed-top navbar-theme-aizio-background">
<div class="inner-navbar"> Test<sub>name</sub>
<div class="container">
<nav id="menu" class="nav" role="navigation">
<ul class="inactive-responsive" id="inactive-responsive">
<li>
<span><i aria-hidden="true" class="icon-home"></i></span>Home
</li>
<li class="inactive-dropdown" id="dropdownToggle"> <span><i aria-hidden="true" class="icon-signal"></i></span>Docs
<ul class="inactive-dropdown vertical-navigation" id="inactive-dropdown">
<li> <span><i aria-hidden="true" class="icon-code"></i></span>ssss
</li>
<li> <span><i aria-hidden="true" class="icon-qrcode"></i></span>Portfolio
</li>
<li> <span><i aria-hidden="true" class="icon-print"></i></span>Blog
</li>
<li> <span><i aria-hidden="true" class="icon-heart"></i></span>The team
</li>
<li><span><i aria-hidden="true" class="icon-envelope"></span></i>google.ro
</li>
</ul>
</li>
<li><span><i aria-hidden="true" class="icon-cog"></i></span>Portfolio
</li>
<li><span><i aria-hidden="true" class="icon-cloud"></i></span>Blog
</li>
<li><span><i aria-hidden="true" class="icon-heart"></i></span>The team
</li>
<li><span><i aria-hidden="true" class="icon-envelope"></span></i>Contact
</li>
</ul>
</nav>
</div>
</div>
</div>
</header>
CSS
.navbar [class^="icon-"],
[class*=" icon-"] {
display: block;
font-size: 32px;
font-size: 2rem;
vertical-align: middle;
background-repeat: no-repeat;
}
.navbar {
background: #4d4d4d;
width: 100%;
-webkit-box-shadow: 0 0 0.9em #555555;
box-shadow: 0 0 0.9em #555555;
}
.navbar-inner {
width: 100%;
}
/*
Navbar Brand Styles
*/
.inner-navbar .brand {
color: #ffffff;
font-size: 32px;
font-size: 2rem;
line-height: 1.5;
padding-right: 24px;
padding-right: 1.5rem;
display: block;
font-family: "Gill Sans", "Gill Sans MT", Calibri, sans-serif;
}
.inner-navbar .brand sub,
sup {
padding-left: 5px;
padding-left: 0.3rem;
font-size: 14px;
font-size: 0.9rem;
}
.inner-navbar .brand:hover {
color: #004b67 /*#383838 */;
text-decoration: none;
}
.inner-navbar nav {
display: block;
font-size: 14px;
font-size: 0.9rem;
font-family: Arial, sans-serif;
z-index: 1000;
}
.inner-navbar nav button#responsiveToggle {
display: none;
}
.inner-navbar nav ul {
padding: 0;
margin: 0 auto;
text-align: center;
}
.inner-navbar nav ul li {
display: block;
float: left;
width: auto;
min-width: 130px;
min-width: 8.1rem;
}
.inner-navbar nav li:first-child a,
li:last-child a {
border-left: 0;
}
.inner-navbar nav ul li a {
display: block;
text-align: center;
text-decoration: none;
line-height: 1.5;
}
.inner-navbar nav a:hover {
color: #004b67;
}
.inactive-dropdown {
display: none;
}
.active-dropdown {
position: absolute;
background-color: #1f2024;
-webkit-border-radius: 0 0 5px 5px;
-moz-border-radius: 0 0 5px 5px;
border-radius: 0 0 5px 5px;
}
.active-dropdown li {
float: left;
clear: both;
line-height: 1.5;
vertical-align: middle;
/* nice blue color background-color: #2aa4cf; */
}
.active-dropdown li a {
display: block;
width: auto;
text-align: left;
line-height: 1.5;
}
.vertical-navigation {
float: none;
}
.vertical-navigation i {
float: left;
line-height: 1.5;
}
/*
Themes
*/
.navbar-theme-blue-marina {
background: #2aa4cf;
}
.navbar-theme-aizio-background,
.active-dropdown li {
background: #004b67;
}
.navbar-theme-aizio-background a {
color: #fff;
}
.navbar-theme-aizio-background ul li a:hover {
color: #b2e558;
}
.navbar-theme-aizio-background .brand:hover {
color: #b2e558;
}
/* ------------------------------ RESPONSIVE STYLES ----------------------------------------------------*/
/*Styles for screen 768px and lower*/
#media screen and (max-width: 768px) {
.active-dropdown {
position: relative;
display: block;
}
.active-dropdown li a {
text-align: center;
}
.inner-navbar nav li {
width: 50%;
float: left;
position: relative;
border-left: 0 solid #666;
}
.inner-navbar nav li a {
border-left: 0;
padding: 10px 0;
background: #383838;
}
.inner-navbar nav li a:hover {
background: #636363;
}
.inner-navbar nav a {
text-align: center;
width: 100%;
}
}
/*Styles for screen 515px and lower*/
#media only screen and (max-width: 480px) {
.inner-navbar nav {
border-bottom: 0;
}
.inner-navbar nav li {
width: 100%;
float: none;
position: relative;
border-left: 0 solid #666;
}
.inner-navbar nav li a {
border-bottom: 1px solid #0c0a0d;
}
.inner-navbar nav button#responsiveToggle {
display: block;
width: 100%;
}
.inner-navbar nav button#responsiveToggle {
zoom: 1;
}
.inner-navbar nav button#responsiveToggle:before {
content: '';
/* 1 */
display: block;
/* 2 */
}
.inner-navbar nav button#responsiveToggle:after {
content: '';
display: table;
clear: both;
}
/* When JavaScript is enabled, we hide the menu */
.js .inner-navbar nav .inactive-responsive {
display: none;
}
/* Displaying the menu when the user has clicked on the button */
.active-responsive a:hover {
font-size: 2em;
opacity: .5;
}
.active-responsive a:hover i {
display: none;
}
.fixed-top {
position: relative;
}
}
/*Smartphone*/
#media only screen and (max-width: 320px) {
.active-dropdown li {
display: block;
float: none;
width: 100%;
}
.inner-navbar nav li {
display: block;
float: none;
width: 100%;
}
.inner-navbar nav li a {
border-bottom: 1px solid #0c0a0d;
}
}
/* RETINA */
/* ------------------------------ RESPONSIVE STYLES ----------------------------------------------------*/
/*Styles for screen 768px and lower*/
#media screen and (max-width: 768px) {
.inner-navbar .brand {
display: none;
}
}
/*Styles for screen 515px and lower*/
/*Smartphone*/
#media only screen and (max-width: 320px) {
.inner-navbar .brand {
display: block;
}
.inner-navbar .pull-left {
float: none;
}
.inner-navbar .pull-right {
float: none;
}
}
/* RETINA */

You have a few problems because styles for the horizontal menu are affecting the vertical one, i made this changes in your CSS:
.inner-navbar nav .vertical-navigation li a{
text-align:left;
}
.vertical-navigation i {
float:none;
line-height: 1.5;
}
.vertical-navigation li [class^="icon-"] {
display: inline-block;
padding: 0 10px;
}
View the demo http://jsfiddle.net/vfubN/13/

I have the same menu and it works. I give you the CSS. You still have more for you to rename.
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>Index</title>
<style type="text/css">
#menu, #menu ul {
padding:0;
margin:0;
list-style: none;
}
#menu li {
display:inline-block;
width:150px;
text-align: center;
background: #999;
}
#menu ul {
position:absolute;
left:-999em;
}
#menu li:hover ul {
left:auto;
}
#menu a {
display:block;
}
</style>
</head>
<body>
<ul id="menu">
<li id='accueil'>accueil</li><!--
--><li><a href="" class='catalogue'>CATALOGUE</a></li><!--
--><li><a class='fonction' href="">FONCTIONNEMENT</a>
<ul>
<li><a href='toto'>toto</a></li><!--
--><li><a href='toto'>tutu</a></li><!--
--><li><a href='toto'>titi</a></li><!--
--><li><a href='toto'>tata</a></li>
</ul>
</li><!--
--><li><a class='service' href="">LES SERVICES</a></li><!--
--><li><a class='commande' href="">COMMANDE</a></li><!--
--><li><a class='contact' href="">CONTACT</a></li>
</ul>
</body>
</html>

Related

multi level drop down menu with css

i want to add multi level dropdown to that w3schools menu.
https://www.w3schools.com/howto/howto_js_responsive_navbar_dropdown.asp
it looks like
original w3schools menu
i tried to make it multi level as you can see.
multi level drop down photo 1
multi level drop down photo 2
My problem is as you can see in the photos; multi level does not close when you are another level. can you fix that ?
<div class="topnav" id="myTopnav">
Home
News
Contact
<div class="dropdown">
<button class="dropbtn">Dropdown
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</div>
About
☰
</div>
`/* Add a black background color to the top navigation */
.topnav {
background-color: #333;
overflow: hidden;
}
/* Style the links inside the navigation bar */
.topnav a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
/* Add an active class to highlight the current page */
.active {
background-color: #04AA6D;
color: white;
}
/* Hide the link that should open and close the topnav on small screens */
.topnav .icon {
display: none;
}
/* Dropdown container - needed to position the dropdown content */
.dropdown {
float: left;
overflow: hidden;
}
/* Style the dropdown button to fit inside the topnav */
.dropdown .dropbtn {
font-size: 17px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font-family: inherit;
margin: 0;
}
/* Style the dropdown content (hidden by default) */
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Style the links inside the dropdown */
.dropdown-content a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
/* Add a dark background on topnav links and the dropdown button on hover */
.topnav a:hover, .dropdown:hover .dropbtn {
background-color: #555;
color: white;
}
/* Add a grey background to dropdown links on hover */
.dropdown-content a:hover {
background-color: #ddd;
color: black;
}
/* Show the dropdown menu when the user moves the mouse over the dropdown button */
.dropdown:hover .dropdown-content {
display: block;
}
/* When the screen is less than 600 pixels wide, hide all links, except for the first one ("Home"). Show the link that contains should open and close the topnav (.icon) */
#media screen and (max-width: 600px) {
.topnav a:not(:first-child), .dropdown .dropbtn {
display: none;
}
.topnav a.icon {
float: right;
display: block;
}
}
/* The "responsive" class is added to the topnav with JavaScript when the user clicks on the icon. This class makes the topnav look good on small screens (display the links vertically instead of horizontally) */
#media screen and (max-width: 600px) {
.topnav.responsive {position: relative;}
.topnav.responsive a.icon {
position: absolute;
right: 0;
top: 0;
}
.topnav.responsive a {
float: none;
display: block;
text-align: left;
}
.topnav.responsive .dropdown {float: none;}
.topnav.responsive .dropdown-content {position: relative;}
.topnav.responsive .dropdown .dropbtn {
display: block;
width: 100%;
text-align: left;
}
}
i changed it like this;
.topnav {
overflow: hidden;
background-color: #333;
}
.topnav a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.active {
background-color: #04AA6D;
color: white;
}
.topnav .icon {
display: none;
}
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 17px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font-family: inherit;
margin: 0;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-submenu {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
top: 0;
left: 100%
}
.dropdown-content a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.topnav a:hover, .dropdown:hover .dropbtn {
background-color: #555;
color: white;
}
.dropdown-content a:hover {
background-color: #ddd;
color: black;
}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown-content:hover .dropdown-submenu {
display: block;
}
#media screen and (max-width: 600px) {
.topnav a:not(:first-child), .dropdown .dropbtn {
display: none;
}
.topnav a.icon {
float: right;
display: block;
}
}
#media screen and (max-width: 600px) {
.topnav.responsive {position: relative;}
.topnav.responsive .icon {
position: absolute;
right: 0;
top: 0;
}
.topnav.responsive a {
float: none;
display: block;
text-align: left;
}
.topnav.responsive .dropdown {float: none;}
.topnav.responsive .dropdown-content {position: relative;}
.topnav.responsive .dropdown .dropbtn {
display: block;
width: 100%;
text-align: left;
}
}
<div class="topnav" id="myTopnav">
Home
News
Contact
<div class="dropdown">
<button class="dropbtn">Dropdown
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
Link 1
<div class="dropdown-submenu">
Link 2</div>
Link 3
</div>
</div>
About
☰
</div>
your issue seems to be with the .dropdown-content:hover .dropdown-submenu { display: block; } part, when you're hovering over 'Link 3', you're still hovering over .dropdown-content

Margin down dropdown content

I'm trying to make Hover dropdown menu and I want to margin-top dropdown content, but when I'm making so it does not work, because when I'm trying to go to dropdown links it disappears as I'm off hover.
See snippet from w3school below. In dropdown-content I have style margin-top:20px.
How can I manage this?
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
body {margin:0;font-family:Arial}
.topnav {
overflow: hidden;
background-color: #333;
}
.topnav a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.active {
background-color: #4CAF50;
color: white;
}
.topnav .icon {
display: none;
}
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 17px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font-family: inherit;
margin: 0;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.topnav a:hover, .dropdown:hover .dropbtn {
background-color: #555;
color: white;
}
.dropdown-content a:hover {
background-color: #ddd;
color: black;
}
.dropdown:hover .dropdown-content {
display: block;
}
#media screen and (max-width: 600px) {
.topnav a:not(:first-child), .dropdown .dropbtn {
display: none;
}
.topnav a.icon {
float: right;
display: block;
}
}
#media screen and (max-width: 600px) {
.topnav.responsive {position: relative;}
.topnav.responsive .icon {
position: absolute;
right: 0;
top: 0;
}
.topnav.responsive a {
float: none;
display: block;
text-align: left;
}
.topnav.responsive .dropdown {float: none;}
.topnav.responsive .dropdown-content {position: relative;}
.topnav.responsive .dropdown .dropbtn {
display: block;
width: 100%;
text-align: left;
}
}
</style>
</head>
<body>
<div class="topnav" id="myTopnav">
Home
News
Contact
<div class="dropdown">
<button class="dropbtn">Dropdown
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content" style="margin-top:20px;">
Link 1
Link 2
Link 3
</div>
</div>
About
☰
</div>
<div style="padding-left:16px">
<h2>Responsive Topnav with Dropdown</h2>
<p>Resize the browser window to see how it works.</p>
<p>Hover over the dropdown button to open the dropdown menu.</p>
</div>
<script>
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
</script>
</body>
</html>
You can wrap your links inside the drop down in another div and use margin-top:20px; for that to bring it down, also you will have to move your background-color and box-shadow to the new div. See the snippet below, hope this helps you
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
body {margin:0;font-family:Arial}
.topnav {
overflow: hidden;
background-color: #333;
}
.topnav a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.active {
background-color: #4CAF50;
color: white;
}
.topnav .icon {
display: none;
}
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 17px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font-family: inherit;
margin: 0;
}
.dropdown-content {
display: none;
position: absolute;
min-width: 160px;
z-index: 1;
}
.dropdown-content div {
background-color: #f9f9f9;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}
.dropdown-content a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.topnav a:hover, .dropdown:hover .dropbtn {
background-color: #555;
color: white;
}
.dropdown-content a:hover {
background-color: #ddd;
color: black;
}
.dropdown:hover .dropdown-content {
display: block;
}
#media screen and (max-width: 600px) {
.topnav a:not(:first-child), .dropdown .dropbtn {
display: none;
}
.topnav a.icon {
float: right;
display: block;
}
}
#media screen and (max-width: 600px) {
.topnav.responsive {position: relative;}
.topnav.responsive .icon {
position: absolute;
right: 0;
top: 0;
}
.topnav.responsive a {
float: none;
display: block;
text-align: left;
}
.topnav.responsive .dropdown {float: none;}
.topnav.responsive .dropdown-content {position: relative;}
.topnav.responsive .dropdown .dropbtn {
display: block;
width: 100%;
text-align: left;
}
}
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
</style>
</head>
<body>
<div class="topnav" id="myTopnav">
Home
News
Contact
<div class="dropdown">
<button class="dropbtn">Dropdown
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content" style="">
<div style="margin-top:20px;">
Link 1
Link 2
Link 3
</div>
</div>
</div>
About
☰
</div>
<div style="padding-left:16px">
<h2>Responsive Topnav with Dropdown</h2>
<p>Resize the browser window to see how it works.</p>
<p>Hover over the dropdown button to open the dropdown menu.</p>
</div>
</body>
</html>

Submenu disappears in Flexbox

When I try to add a site navigation into a flexbox layout the submenus become not accessible anymore. They disappear when the mouse leaves the parent list element.
The final goal is to make the navigation fixed by using flexbox. If the body- and header-tag are left out the navigation works like intended. Any ideas on this?
* {
margin: 0;
padding: 0;
}
body {
display: flex;
flex-direction: column;
}
header {
flex: 0 0 auto;
background: yellow;
}
.site-navigation {
font-family: 'Open Sans', 'Helvetica', 'Arial', sans-serif;
font-weight: 400;
color: #666;
}
nav ul {
background: none;
display: flex;
flex-direction: column;
}
nav ul li {
list-style-type: none;
background: none;
}
nav ul li:hover {
background: none;
}
nav ul li a {
padding: 0.8rem 1rem;
display: block;
text-decoration: none;
color: rgba(100, 100, 100, 0.8);
background: none;
text-transform: uppercase;
font-size: 12px;
}
.has-children:hover>a {
border: 1px solid #e5e5e5;
border-bottom: none;
background: #fff;
margin-left: -1px;
margin-right: -1px;
margin-top: -1px;
color: #000;
}
.has-children:hover>ul {
border: 1px solid #e5e5e5;
position: relative;
z-index: -1;
}
.has-children:hover>ul>li {
padding: 15px 15px;
}
.has-children>ul>li>a {
text-transform: none;
color: #666;
border-bottom: 1px solid #E5E5E5;
padding: 0;
padding-bottom: 15px;
}
.has-children>ul>li:hover>a {
border-bottom: 2px solid #d00;
color: #000;
padding-bottom: 14px;
}
#media only screen and (min-width:680px) {
nav ul {
flex-direction: row;
}
nav ul li {
position: relative;
flex: 0 0 auto;
text-align: left;
}
nav ul li:hover ul {
display: flex;
flex-direction: column;
}
.has-children ul {
display: none;
position: absolute;
top: 100%;
}
.has-children:hover ul {
display: block;
position: absolute;
top: calc( 100% - 1px);
width: 150%;
}
}
<header class="site-header">
<nav class="site-navigation">
<ul class="site-navigation__list">
<li class="site-navigation__item">Item 1
</li>
<li class="site-navigation__item has-children">Item 2<span class="arrow arrow-down"></span>
<ul class="site-navigation__sub-list">
<li class="site-navigation__sub-item">Subitem 1</li>
<li class="site-navigation__sub-item">Subitem 2</li>
</ul>
</li>
</ul>
</nav>
</header>
<div class="content"><p>Content goes here!</p></div>
It seems to be a matter of z-index and background.
You may use position:relative to reset z-index and add a background to submenu to hide overlapped content.
CSS update that could be done:
nav ul {
position:relative;
z-index:1
}
nav ul li:hover > ul{
background: white;
}
* {
margin: 0;
padding: 0;
}
body {
display: flex;
flex-direction: column;
}
header {
flex: 0 0 auto;
background: yellow;
}
.site-navigation {
font-family: 'Open Sans', 'Helvetica', 'Arial', sans-serif;
font-weight: 400;
color: #666;
}
nav ul {
background: none;
display: flex;
flex-direction: column;
}
nav ul {
position:relative;
z-index:1
}
nav ul li:hover > ul{
background: white;
}
nav ul li ,nav ul li:hover{
list-style-type: none;
background: none;
}
nav ul li a {
padding: 0.8rem 1rem;
display: block;
text-decoration: none;
color: rgba(100, 100, 100, 0.8);
background: none;
text-transform: uppercase;
font-size: 12px;
}
.has-children:hover>a {
border: 1px solid #e5e5e5;
border-bottom: none;
background: #fff;
margin-left: -1px;
margin-right: -1px;
margin-top: -1px;
color: #000;
}
.has-children:hover>ul {
border: 1px solid #e5e5e5;
position: relative;
z-index: -1;
}
.has-children:hover>ul>li {
padding: 15px 15px;
}
.has-children>ul>li>a {
text-transform: none;
color: #666;
border-bottom: 1px solid #E5E5E5;
padding: 0;
padding-bottom: 15px;
}
.has-children>ul>li:hover>a {
border-bottom: 2px solid #d00;
color: #000;
padding-bottom: 14px;
}
#media only screen and (min-width:680px) {
nav ul {
flex-direction: row;
}
nav ul li {
position: relative;
flex: 0 0 auto;
text-align: left;
}
nav ul li:hover ul {
display: flex;
flex-direction: column;
}
.has-children ul {
display: none;
position: absolute;
top: 100%;
}
.has-children:hover ul {
display: block;
position: absolute;
top: calc( 100% - 1px);
width: 150%;
}
}
<header class="site-header">
<nav class="site-navigation">
<ul class="site-navigation__list">
<li class="site-navigation__item">Item 1
</li>
<li class="site-navigation__item has-children">Item 2<span class="arrow arrow-down"></span>
<ul class="site-navigation__sub-list">
<li class="site-navigation__sub-item">Subitem 1</li>
<li class="site-navigation__sub-item">Subitem 2</li>
</ul>
</li>
</ul>
</nav>
</header>
<div class="content"><p>Content goes here!</p></div>
Another update maybe to show submenu when parent is hovered ?
.has-children>ul {
display:none;
}
.has-children:hover>ul {
display:block;
}
https://codepen.io/anon/pen/MvKqqE

IE9 list spacing issue

I have a list of anchor links that display correctly in IE10+, Chrome, etc, but IE9 is adding padding between the elements that shouldn't be there.
This is how it looks in IE10/Chrome:
But IE9 is rendering the links incorrectly:
HTML
<div class="jump-to-links">
<ul class="list-group">
<li>
Link Title<i class="material-icons arrow-down">keyboard_arrow_down</i>
</li>
<li>
Link Title<i class="material-icons arrow-down">keyboard_arrow_down</i>
</li>
<li>
Link Title<i class="material-icons arrow-down">keyboard_arrow_down</i>
</li>
<li>
Link Title<i class="material-icons arrow-down">keyboard_arrow_down</i>
</li>
</ul>
</div>
CSS
// TARGETING EI9+
#media screen and (min-width: 0\0) {
.jump-to-links{
ul{
white-space: nowrap;
}
ul li{
padding: 0;
margin: 0;
}
}
}
.jump-to-links {
text-align: center;
a,a:hover {
text-decoration: none;
color: $black;
font-weight: bold;
display: inline-block;
}
ul li {
display: inline-block;
padding: 0px 60px 0px 0px;
}
li {
cursor: pointer;
}
.arrow-down {
display: block;
}
}
/***************** DESKTOP **************/
#media (min-width: $screen-lg-min) {
.jump-to-links{
a{
font-size: 17px;
}
.arrow-down{
color: $purple;
}
}
}
/***************** TABLET **************/
#media (min-width: $screen-sm-min) and (max-width: $screen-lg-min) {
.jump-to-links{
text-align: left;
ul li{
display: block;
padding: 10px 30px;
border-bottom: 1px solid $accordion-border;
}
.arrow-down{
float: right;
color: $purple;
}
}
}
/****************** MOBILE ***************/
#media (max-width: $screen-xs-max) {
.jump-to-links{
padding: 0px 0px 0px 0px;
text-align: left;
ul li{
display: block;
padding: 10px 30px;
border-bottom: 1px solid $accordion-border;
}
.arrow-down{
float: right;
color: $purple;
}
}
}
Rendered CSS in IE9:

Submenu not working with IE7 (child menu not opening)

I am working on horizontal menu bar and I’ve used following line code. It is working fine in all browsers:
but when I’m testing it on IE7 & 8 then sub menu not opening.
When I removed the shadow from navMenu bar then sub menu items will be visible.
Html Code:
<div id="navMenu">
<div id="menuContainer">
<ul id="coolMenu">
<li>Menu1</li>
<li>Menu2</li>
<li>Menu3 </li>
<li>Menu4
<ul>
<li>Menu5</li>
<li>Menu6</li>
<li>Menu7</li>
</ul>
</li>
</ul>
</div>
</div>
CSS Code:
#navMenu
{
height: 40px;
line-height: 40px;
background-color: #dcdcdc;
position: relative;
z-index: 40000 !important;
margin-left: auto;
margin-right: auto;
min-width: 100%;
overflow:visible;
}
#menuContainer
{
padding: 0px;
text-align: left;
width: 1200px;
margin: 0px auto;
z-index: 40000 !important;
overflow:visible;
}
#coolMenu, #coolMenu ul
{
padding: 0px;
text-align: left;
list-style: none;
list-style-type: none; /* ie6*/
}
#coolMenu > li
{
float: left;
z-index: 40000 !important;
display: block; /* ie6*/
}
#coolMenu li a
{
display: block;
height: 40px;
line-height: 40px;
padding-left: 15px;
padding-right: 15px;
text-decoration: none;
z-index: 40000 !important;
display: block; /* ie6*/
filter:alpha(opacity=90);
}
#coolMenu ul
{
position: absolute;
display: none;
z-index: 40000 !important; /* arun */
}
#coolMenu li:hover ul
{
display: block;
}
/* Main menu
------------------------------------------*/
#coolMenu
{
margin: 0px;
float: left;
font-family: TradeGothic;
font-style: oblique;
font-size: 11.25px;
color: #474747;
background: #dcdcdc;
z-index: 40000 !important;
}
#coolMenu > li > a
{
color: #474747;
}
#coolMenu > li:hover > a
{
background: #d21c1c;
color: #fff;
z-index: 40000 !important; /* arun */
}
/* dropdown */
#coolMenu li:hover > ul {
display: block;
}
/* Submenu
------------------------------------------*/
#coolMenu ul
{
background: #d21c1c;
z-index: 40000 !important;
}
#coolMenu ul li a
{
/*z-index: 20 !important;*/
color: #fff;
z-index: 40000 !important;
}
#coolMenu ul li:hover a
{
background: red;
z-index: 40000 !important;
}
ul is take by default margin. so
#coolMenu ul{margin:0;}
Solve your problem in ie7

Resources