Pseudo active class not working in scss file - html

Not Working
This is my simple header of navigation and logo
<header>
<div class="logo" style="width: 11%;">
<img src="Images/logo.png" style="width: 100%;">
</div>
<nav>
<ul>
<li>
<a href="#" >HOME</a>
</li>
<li>
ABOUT US
</li>
<li>
SERVICES
</li>
<li>
CONTACT US
</li>
<li>
TESTIMONIALS
</li>
<li>
FAQ
</li>
<li>
CONTACT US
</li>
</ul>
</nav>
</header>
My CSS in which active class is not working while others are working well
li
{
display: inline-block;
font-size: 18px;
a
{
display: inline-block;
color:$secondary;
padding: 17px;
&:active
{
padding: 10px;
background : blue;
font-weight: bold;
}
}
}
Whether you use hover or focus it will work but active pseudo class is not in progress
can anyone help

Your confused between pseudo-classes and CSS classes what you need here is a CSS class to be set on the active list item and to do that you need to add some JS
var header = document.getElementById("myDIV");
var btns = header.getElementsByClassName("li");
for (var i = 0; i < btns.length; i++) {
btns[i].addEventListener("click", function() {
var current = document.getElementsByClassName("active");
current[0].className = current[0].className.replace(" active", "");
this.className += " active";
});
}
li{
display: inline-block;
font-size: 18px;
a
{
display: inline-block;
color: gray;
padding: 17px;
}
}
.active{
padding: 10px;
background : blue;
font-weight: bold;
}
<header>
<div class="logo" style="width: 11%;">
<img src="Images/logo.png" style="width: 100%;">
</div>
<nav>
<ul id="myDIV">
<li class="li active">
<a href="#" >HOME</a>
</li>
<li class="li">
ABOUT US
</li>
<li class="li">
SERVICES
</li>
<li class="li">
CONTACT US
</li>
<li class="li">
TESTIMONIALS
</li>
<li class="li">
FAQ
</li>
<li class="li">
CONTACT US
</li>
</ul>
</nav>
</header>

Related

How can i make active background color for two elements in nav menu

I have a vertical navbar menu with 2 blocks.
First is nav with icons, second is text of menu.
They have a different background colors. How i can make one background color for two active nav blocks?
design of menu
<div class="menu__icons">
<ul class="menu__list">
<li>
<a class="menu__item" href="#"><img src="http://via.placeholder.com/50" alt=""></a>
</li>
<li>
<a class="menu__item" href="#"><img src="http://via.placeholder.com/50" alt=""></a>
</li>
<li>
<a class="menu__item" href="#"><img src="http://via.placeholder.com/50" alt=""></a>
</li>
<li>
<a class="menu__item" href="#"><img src="http://via.placeholder.com/50" alt=""></a>
</li>
</ul>
</div>
<div class="menu__text">
<ul class="menu__list">
<li><a class="menu__item" href="#">First</a></li>
<li><a class="menu__item" href="#">Second</a></li>
<li><a class="menu__item" href="#">Third</a></li>
<li><a class="menu__item" href="#">Fourth</a></li>
</ul>
</div>
</div>
https://jsfiddle.net/levan563/1g5ucmwq/2/
Well basically if you want to toggle .active and you don't want two separate markup of list.
Notice that font-awesome is for demonstration purposes only.
.menu__item {
width: 250px;
height: 50px;
text-align: left;
}
.menu__item.active {
background-color: #e9ebfd;
}
.menu__item.active .menu__icon {
background-color: #e9ebfd;
border-left: 4px solid #2c39ec;
}
.menu__item.active .menu__title {
background-color: #e9ebfd;
}
.menu__item a:hover {
text-decoration: none;
}
.menu__icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: 50px;
height: 50px;
background-color: #fafafa;
color: #2c39ec;
}
.menu__title {
display: inline-block;
padding-left: 20px;
color: #777777;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/all.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navigation-menu">
<ul class="menu__list list-unstyled">
<li class="menu__item active">
<a href="#">
<div class="menu__icon">
<i class="fa fa-tachometer-alt"></i>
</div>
<div class="menu__title">Main Dashboard</div>
</a>
</li>
<li class="menu__item">
<a href="#">
<div class="menu__icon">
<i class="fa fa-user"></i>
</div>
<div class="menu__title">Profile</div>
</a>
</li>
<li class="menu__item">
<a href="#">
<div class="menu__icon">
<i class="fa fa-bell"></i>
</div>
<div class="menu__title">Finances</div>
</a>
</li>
<li class="menu__item">
<a href="#">
<div class="menu__icon">
<i class="fa fa-calendar"></i>
</div>
<div class="menu__title">Titles</div>
</a>
</li>
</ul>
</nav>
Related Fiddle https://jsfiddle.net/mhrabiee/dojL9get/28/
As I understand take active class for both block's li and try to use font, svg icon or transparent background images instead of block images
.menu__list .active {
background-color: red;
}
<div class="menu__icons">
<ul class="menu__list">
<li><a class="menu__item active" href="#">
<img src="https://img.icons8.com/material/24/000000/tailoring-for-men.png">
</a></li>
</ul>
</div>
<div class="menu__text">
<ul class="menu__list">
<li><a class="menu__item active" href="#">First</a></li>
</ul>
</div>
Its doable using jQuery.
Assuming you have same number of list items in both blocks,
$(function(){
$('.menu__list li').on('click', function() {
var idx = $(this).index();
$('.menu__list li').removeClass('active');
$('.menu__list li:nth-child(' + idx + ')').addClass('active');
});
});
also add .active class in css and give needed style to li items also
.active{
/**your style**/
}
.active > a{
}
.active img{
}

5 responsive floating divs not aligning properly on mobile/tablet view (<992px)

I have 5 side by side lists in my website's footer as follows:
<div class="row">
<div class="col-xs-12 footer-links">
<div class="links">
<h1 class="title">ABOUT US</h1>
<ul>
<li class="link"> About Company</li>
<li class="link"> Legal Documents</li>
<li class="link"> Careers</li>
<li class="link"> Contact Us</li>
<li class="link"> FAQs</li>
</ul>
</div>
<div class="links">
<h1 class="title">ACCOUNTS</h1>
<ul>
<li class="link">Register</li>
<li class="link">Compare Account Types</li>
<li class="link">Funding Options</li>
<li class="link">Islamic Account</li>
</ul>
</div>
<div class="links">
<h1 class="title">INSTRUMENTS</h1>
<ul>
<li class="link"> Currencies</li>
<li class="link"> Commodities</li>
<li class="link"> Metals</li>
<li class="link"> Shares</li>
<li class="link"> Bonds</li>
<li class="link"> Indices</li>
</ul>
</div>
<div class="links">
<h1 class="title">PLATFORMS</h1>
<ul>
<li class="link"> Meta Trader 4</li>
<li class="link"> MT4 Desktop</li>
<li class="link"> MT4 iOS</li>
<li class="link"> MT4 Android</li>
<li class="link"> MT4 Webtrader</li>
</ul>
</div>
<div class="links">
<h1 class="title">TRADING TOOLS</h1>
<ul>
<li class="link"> Expiration Dates</li>
<li class="link"> Market Hours</li>
<li class="link"> Holiday Calendar</li>
<li class="link"> Economic Calendar</li>
</ul>
</div>
</div>
What I would like to happen is that at any resolution below 992px, the lists will each take up 50% of the column creating 3 rows of 2 lists each except for the last (since I have 5 lists)
Here is my sass code: (maxMQ is just a mixin for a media query and $md-max-width is 992px)
.footer {
.links {
float: left;
display: inline-block;
width: calc(100% / 5);
#include maxMQ($md-max-width) {
margin-top: 30px;
width: 50%;
}
.title {
font-size: 14px;
margin-bottom: 5px;
padding-bottom: 7px;
display: inline-block;
border-bottom: 2px solid $highlight-blue;
}
ul {
margin: 0;
padding: 0;
display: block;
}
li {
margin-top: 5px;
font-size: 13px;
a {
color: #ffffff;
text-decoration: none;
cursor: pointer;
}
}
}
The problem is that when I reduce resolution below 992px (mobile/tablet), the 3rd list skips a spot on the second row. so it looks something like this:
row 1: list list
row 2: list
row 3: list list
What I want is:
row 1: list list
row 2: list list
row 3: list
I have no idea why this is happening. I do know that when I remove the ul's from within the 'links' divs it works fine.
Any help would be greatly appreciated! Thanks!
This is due to the floating elements, the first element has more height than the second one and it's creating this issue on the second row.
To fix this and you can use flex and remove the floating:
.links {
float: left;
display: inline-block;
width: calc(100% / 5);
}
#media all and (max-width:992px) {
.footer-links {
display: flex;
flex-wrap:wrap;
}
.links {
margin-top: 30px;
width: 50%;
float: none;
}
.title {
font-size: 14px;
margin-bottom: 5px;
padding-bottom: 7px;
display: inline-block;
border-bottom: 2px solid $highlight-blue;
}
ul {
margin: 0;
padding: 0;
display: block;
}
li {
margin-top: 5px;
font-size: 13px;
}
li a {
color: #000 text-decoration: none;
cursor: pointer;
}
}
<div class="row">
<div class="col-xs-12 footer-links">
<div class="links">
<h1 class="title">ABOUT US</h1>
<ul>
<li class="link"> About Company</li>
<li class="link"> Legal Documents</li>
<li class="link"> Careers</li>
<li class="link"> Contact Us</li>
<li class="link"> FAQs</li>
</ul>
</div>
<div class="links">
<h1 class="title">ACCOUNTS</h1>
<ul>
<li class="link">Register</li>
<li class="link">Compare Account Types</li>
<li class="link">Funding Options</li>
<li class="link">Islamic Account</li>
</ul>
</div>
<div class="links">
<h1 class="title">INSTRUMENTS</h1>
<ul>
<li class="link"> Currencies</li>
<li class="link"> Commodities</li>
<li class="link"> Metals</li>
<li class="link"> Shares</li>
<li class="link"> Bonds</li>
<li class="link"> Indices</li>
</ul>
</div>
<div class="links">
<h1 class="title">PLATFORMS</h1>
<ul>
<li class="link"> Meta Trader 4</li>
<li class="link"> MT4 Desktop</li>
<li class="link"> MT4 iOS</li>
<li class="link"> MT4 Android</li>
<li class="link"> MT4 Webtrader</li>
</ul>
</div>
<div class="links">
<h1 class="title">TRADING TOOLS</h1>
<ul>
<li class="link"> Expiration Dates</li>
<li class="link"> Market Hours</li>
<li class="link"> Holiday Calendar</li>
<li class="link"> Economic Calendar</li>
</ul>
</div>
</div>
Or simply remove floating without adding flex but you need to fix white spaces issue to have them 50% width:
.links {
float: left;
display: inline-block;
width: calc(100% / 5);
}
#media all and (max-width:992px) {
.footer-links {
font-size: 0; /* remove white spaces */
}
.links {
margin-top: 30px;
width: 50%;
float: none;
font-size: initial; /* put back font as initial*/
vertical-align:top;
}
.title {
font-size: 14px;
margin-bottom: 5px;
padding-bottom: 7px;
display: inline-block;
border-bottom: 2px solid $highlight-blue;
}
ul {
margin: 0;
padding: 0;
display: block;
}
li {
margin-top: 5px;
font-size: 13px;
}
li a {
color: #000 text-decoration: none;
cursor: pointer;
}
}
<div class="row">
<div class="col-xs-12 footer-links">
<div class="links">
<h1 class="title">ABOUT US</h1>
<ul>
<li class="link"> About Company</li>
<li class="link"> Legal Documents</li>
<li class="link"> Careers</li>
<li class="link"> Contact Us</li>
<li class="link"> FAQs</li>
</ul>
</div>
<div class="links">
<h1 class="title">ACCOUNTS</h1>
<ul>
<li class="link">Register</li>
<li class="link">Compare Account Types</li>
<li class="link">Funding Options</li>
<li class="link">Islamic Account</li>
</ul>
</div>
<div class="links">
<h1 class="title">INSTRUMENTS</h1>
<ul>
<li class="link"> Currencies</li>
<li class="link"> Commodities</li>
<li class="link"> Metals</li>
<li class="link"> Shares</li>
<li class="link"> Bonds</li>
<li class="link"> Indices</li>
</ul>
</div>
<div class="links">
<h1 class="title">PLATFORMS</h1>
<ul>
<li class="link"> Meta Trader 4</li>
<li class="link"> MT4 Desktop</li>
<li class="link"> MT4 iOS</li>
<li class="link"> MT4 Android</li>
<li class="link"> MT4 Webtrader</li>
</ul>
</div>
<div class="links">
<h1 class="title">TRADING TOOLS</h1>
<ul>
<li class="link"> Expiration Dates</li>
<li class="link"> Market Hours</li>
<li class="link"> Holiday Calendar</li>
<li class="link"> Economic Calendar</li>
</ul>
</div>
</div>
Or you can simply add a min-height to your elements to be sure they have the same height:
.links {
float: left;
display: inline-block;
width: calc(100% / 5);
}
#media all and (max-width:992px) {
.links {
margin-top: 30px;
width: 50%;
min-height:170px; /* adjust this value with want you what*/
}
.title {
font-size: 14px;
margin-bottom: 5px;
padding-bottom: 7px;
display: inline-block;
border-bottom: 2px solid $highlight-blue;
}
ul {
margin: 0;
padding: 0;
display: block;
}
li {
margin-top: 5px;
font-size: 13px;
}
li a {
color: #000 text-decoration: none;
cursor: pointer;
}
}
<div class="row">
<div class="col-xs-12 footer-links">
<div class="links">
<h1 class="title">ABOUT US</h1>
<ul>
<li class="link"> About Company</li>
<li class="link"> Legal Documents</li>
<li class="link"> Careers</li>
<li class="link"> Contact Us</li>
<li class="link"> FAQs</li>
</ul>
</div>
<div class="links">
<h1 class="title">ACCOUNTS</h1>
<ul>
<li class="link">Register</li>
<li class="link">Compare Account Types</li>
<li class="link">Funding Options</li>
<li class="link">Islamic Account</li>
</ul>
</div>
<div class="links">
<h1 class="title">INSTRUMENTS</h1>
<ul>
<li class="link"> Currencies</li>
<li class="link"> Commodities</li>
<li class="link"> Metals</li>
<li class="link"> Shares</li>
<li class="link"> Bonds</li>
<li class="link"> Indices</li>
</ul>
</div>
<div class="links">
<h1 class="title">PLATFORMS</h1>
<ul>
<li class="link"> Meta Trader 4</li>
<li class="link"> MT4 Desktop</li>
<li class="link"> MT4 iOS</li>
<li class="link"> MT4 Android</li>
<li class="link"> MT4 Webtrader</li>
</ul>
</div>
<div class="links">
<h1 class="title">TRADING TOOLS</h1>
<ul>
<li class="link"> Expiration Dates</li>
<li class="link"> Market Hours</li>
<li class="link"> Holiday Calendar</li>
<li class="link"> Economic Calendar</li>
</ul>
</div>
</div>
Another easy fix for your situation is to clear floating after each last element of each row by using clear:left (but you need to adjust this if you change your logic, for example 3 per row instead of 2 per row):
.links {
float: left;
display: inline-block;
width: calc(100% / 5);
}
#media all and (max-width:992px) {
.links {
margin-top: 30px;
width: 50%;
}
/* Added this code*/
.links:nth-child(2n+1) {
clear:left;
}
/**/
.title {
font-size: 14px;
margin-bottom: 5px;
padding-bottom: 7px;
display: inline-block;
border-bottom: 2px solid $highlight-blue;
}
ul {
margin: 0;
padding: 0;
display: block;
}
li {
margin-top: 5px;
font-size: 13px;
}
li a {
color: #000 text-decoration: none;
cursor: pointer;
}
}
<div class="row">
<div class="col-xs-12 footer-links">
<div class="links">
<h1 class="title">ABOUT US</h1>
<ul>
<li class="link"> About Company</li>
<li class="link"> Legal Documents</li>
<li class="link"> Careers</li>
<li class="link"> Contact Us</li>
<li class="link"> FAQs</li>
</ul>
</div>
<div class="links">
<h1 class="title">ACCOUNTS</h1>
<ul>
<li class="link">Register</li>
<li class="link">Compare Account Types</li>
<li class="link">Funding Options</li>
<li class="link">Islamic Account</li>
</ul>
</div>
<div class="links">
<h1 class="title">INSTRUMENTS</h1>
<ul>
<li class="link"> Currencies</li>
<li class="link"> Commodities</li>
<li class="link"> Metals</li>
<li class="link"> Shares</li>
<li class="link"> Bonds</li>
<li class="link"> Indices</li>
</ul>
</div>
<div class="links">
<h1 class="title">PLATFORMS</h1>
<ul>
<li class="link"> Meta Trader 4</li>
<li class="link"> MT4 Desktop</li>
<li class="link"> MT4 iOS</li>
<li class="link"> MT4 Android</li>
<li class="link"> MT4 Webtrader</li>
</ul>
</div>
<div class="links">
<h1 class="title">TRADING TOOLS</h1>
<ul>
<li class="link"> Expiration Dates</li>
<li class="link"> Market Hours</li>
<li class="link"> Holiday Calendar</li>
<li class="link"> Economic Calendar</li>
</ul>
</div>
</div>
inline-block automatically adds some margin to the elements, I believe around 4px. So 50% plus that 4px will make it more than 100%, pushing down the elements. Try changing to just block instead.

Child element z-index inside element with transform property

I'm having a problem and I'd like to know if you guys can help me out with it.
As shown in the snippet, I have some elements with
transform: translate(0,0);
And then, inside them, I have a "dropdown" element that is shown when you click a button.
The problem comes when part of this dropdown gets hidden behind other elements, and I found out that this is happening because its parent element has this transform property.
My code has more stuff, the snippet is just an example. I can't get rid of the transform property.
I'd like to know if there is any solution for this. I'm trying to solve it using just CSS.
Cheers!!
$(document).ready(function() {
$('button[name="button"]').click(function(e) {
$(e.currentTarget).parent().find('.template-options-dropdown').toggleClass('open');
});
});
.boxes {
list-style-type: none;
}
.boxes >li {
float: left;
width: 100px;
height: 100px;
background-color: red;
margin: 5px;
transform: translate(0, 0);
}
.download-container {
background: rgba(40, 39, 39, 0.8);
bottom: 0;
position: absolute;
text-align: center;
width: 100%;
}
.download-container .dropdown-container {
display: inline-block;
position: relative;
}
.download-container .dropdown-container button {
background: #0bb9ab;
color: #fff;
padding: 6px 12px;
}
.template-options-dropdown {
list-style-type: none;
text-align: left;
padding: 0;
position: absolute;
background-color: #111;
visibility: hidden;
}
.template-options-dropdown.open {
visibility: visible;
}
.template-options-dropdown li a {
color: white;
text-decoration: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul class="boxes">
<li>
<div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div>
</li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
</ul>
Unfortunately, there maybe no CSS-only solution - CSS3 transitions creates a new stacking context - see the relevant doc description and this thread for another effect:
If the property has a value different than none, a stacking context
will be created.
Source: MDN
You can easily replace translate(0,0) there with position: relative and add a z-index more than zero to .template-options-dropdown to solve the problem.
$(document).ready(function() {
$('button[name="button"]').click(function(e) {
$(e.currentTarget).parent().find('.template-options-dropdown').toggleClass('open');
});
});
.boxes {
list-style-type: none;
}
.boxes >li {
float: left;
width: 100px;
height: 100px;
background-color: red;
margin: 5px;
/*transform: translate(0, 0);*/
position: relative; /*ADDED*/
}
.download-container {
background: rgba(40, 39, 39, 0.8);
bottom: 0;
position: absolute;
text-align: center;
width: 100%;
}
.download-container .dropdown-container {
display: inline-block;
position: relative;
}
.download-container .dropdown-container button {
background: #0bb9ab;
color: #fff;
padding: 6px 12px;
}
.template-options-dropdown {
list-style-type: none;
text-align: left;
padding: 0;
position: absolute;
background-color: #111;
visibility: hidden;
z-index: 2;/*ADDED*/
}
.template-options-dropdown.open {
visibility: visible;
}
.template-options-dropdown li a {
color: white;
text-decoration: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul class="boxes">
<li>
<div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div>
</li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
</ul>
A hacky solution that messes up the wrapping - you can add more transforms:
Add scaleY(-1) for the ul to make the list backwards because of the fact that the a list item with higher index comes over the one with a lower index.
Add an inversion scaleY(-1) to the li to bring the world back to normal.
Also clear the li floats.
See demo below:
$(document).ready(function() {
$('button[name="button"]').click(function(e) {
$(e.currentTarget).parent().find('.template-options-dropdown').toggleClass('open');
});
});
.boxes {
list-style-type: none;
transform: scaleY(-1);/*ADDED*/
}
.boxes:after {/*ADDED*/
content: '';
clear: both;
display: block;
}
.boxes >li {
float: left;
width: 100px;
height: 100px;
background-color: red;
margin: 5px;
transform: translate(0, 0) scaleY(-1);/*ADDED*/
}
.download-container {
background: rgba(40, 39, 39, 0.8);
bottom: 0;
position: absolute;
text-align: center;
width: 100%;
}
.download-container .dropdown-container {
display: inline-block;
position: relative;
}
.download-container .dropdown-container button {
background: #0bb9ab;
color: #fff;
padding: 6px 12px;
}
.template-options-dropdown {
list-style-type: none;
text-align: left;
padding: 0;
position: absolute;
background-color: #111;
visibility: hidden;
}
.template-options-dropdown.open {
visibility: visible;
}
.template-options-dropdown li a {
color: white;
text-decoration: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul class="boxes">
<li>
<div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div>
</li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
</ul>
If translate(0,0) still can't be removed, you have no option other than use javascript:
Invert the list stacking by giving a z-index equal to the index in the list.
Add position:relative to the li
See demo below:
$(document).ready(function() {
// ADDED
$($('ul.boxes > li').get().reverse()).each(function(index){
$(this).css('z-index', index);
});
$('button[name="button"]').click(function(e) {
$(e.currentTarget).parent().find('.template-options-dropdown').toggleClass('open');
});
});
.boxes {
list-style-type: none;
}
.boxes >li {
float: left;
width: 100px;
height: 100px;
background-color: red;
margin: 5px;
transform: translate(0, 0);
position: relative;/*ADDED*/
}
.download-container {
background: rgba(40, 39, 39, 0.8);
bottom: 0;
position: absolute;
text-align: center;
width: 100%;
}
.download-container .dropdown-container {
display: inline-block;
position: relative;
}
.download-container .dropdown-container button {
background: #0bb9ab;
color: #fff;
padding: 6px 12px;
}
.template-options-dropdown {
list-style-type: none;
text-align: left;
padding: 0;
position: absolute;
background-color: #111;
visibility: hidden;
}
.template-options-dropdown.open {
visibility: visible;
}
.template-options-dropdown li a {
color: white;
text-decoration: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul class="boxes">
<li>
<div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div>
</li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
</ul>
z-index will only work on an element whose position property has been explicitly set to absolute, fixed, or relative. So apply position: relative to the li element.
For fixed number of elements, you can try
.boxes li:nth-child(1) {
z-index: 8;
}
.boxes li:nth-child(2) {
z-index: 7;
}
.boxes li:nth-child(3) {
z-index: 6;
}
.boxes li:nth-child(4) {
z-index: 5;
}
.boxes li:nth-child(5) {
z-index: 4;
}
.boxes li:nth-child(6) {
z-index: 3;
}
.boxes li:nth-child(7) {
z-index: 2;
}
.boxes li:nth-child(8) {
z-index: 1;
}
Or for unknown number of elements, you can apply it dynamically with the script.
$(document).ready(function() {
$('button[name="button"]').click(function(e) {
$(e.currentTarget).parent().find('.template-options-dropdown').toggleClass('open');
});
});
.boxes {
list-style-type: none;
}
.boxes >li {
float: left;
width: 100px;
height: 100px;
background-color: red;
margin: 5px;
transform: translate(0, 0);
position: relative;
}
.download-container {
background: rgba(40, 39, 39, 0.8);
bottom: 0;
position: absolute;
text-align: center;
width: 100%;
}
.download-container .dropdown-container {
display: inline-block;
position: relative;
}
.download-container .dropdown-container button {
background: #0bb9ab;
color: #fff;
padding: 6px 12px;
}
.template-options-dropdown {
list-style-type: none;
text-align: left;
padding: 0;
position: absolute;
background-color: #111;
visibility: hidden;
}
.template-options-dropdown.open {
visibility: visible;
}
.template-options-dropdown li a {
color: white;
text-decoration: none;
}
.boxes li:nth-child(1) {
z-index: 8;
}
.boxes li:nth-child(2) {
z-index: 7;
}
.boxes li:nth-child(3) {
z-index: 6;
}
.boxes li:nth-child(4) {
z-index: 5;
}
.boxes li:nth-child(5) {
z-index: 4;
}
.boxes li:nth-child(6) {
z-index: 3;
}
.boxes li:nth-child(7) {
z-index: 2;
}
.boxes li:nth-child(8) {
z-index: 1;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul class="boxes">
<li>
<div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div>
</li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
</ul>
You're close, but if it was me I would set the .open class on either the <li> or the div.download-container, set a massive z-index using that, and use the cascade to open the sub-menu. We also have to set position:relative; on the element that we're setting z-index on, otherwise z-index does nothing.
Example:
$(document).ready(function() {
$('button[name="button"]').click(function(e) {
$(e.currentTarget).parents('li').toggleClass('open');
});
});
.boxes {
list-style-type: none;
}
.boxes >li {
float: left;
width: 100px;
height: 100px;
background-color: red;
margin: 5px;
transform: translate(0, 0);
position:relative;
}
.boxes >li.open {
z-index:500;
}
.download-container {
background: rgba(40, 39, 39, 0.8);
bottom: 0;
position: absolute;
text-align: center;
width: 100%;
}
.download-container .dropdown-container {
display: inline-block;
position: relative;
}
.download-container .dropdown-container button {
background: #0bb9ab;
color: #fff;
padding: 6px 12px;
}
.template-options-dropdown {
list-style-type: none;
text-align: left;
padding: 0;
position: absolute;
background-color: #111;
visibility: hidden;
}
.boxes li.open .template-options-dropdown {
visibility: visible;
}
.template-options-dropdown li a {
color: white;
text-decoration: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul class="boxes">
<li>
<div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div>
</li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
Original
</li>
<li>
Thumb
</li>
<li>
Mobile
</li>
<li>
Tab
</li>
<li>
Web
</li>
<li>
Large web
</li>
</ul>
</div>
</div></li>
</ul>

Responsive Navigation with a nested uls

I'm trying to make my website responsive, but I'm having trouble getting my navigation to work correctly. I've tried adjusting the heights, but it's not aligning.
https://jsfiddle.net/ethacker/hcctkjok/2/
I would like the secondary menu (the one that appears when you hover over a parent menu list item) to be the same height as the "parent" menu (the one that says home, pregnancy, all about baby, etc). I use the PHP file extension, but have just pasted the "header" and "header2" code where it would be if it were all in the single file.
<body>
<header>
<nav>
<h1><a href="index.php"><img src="mommyinfologo.png"/></h1>
<ul class="navMenu">
<a href="index.php">
<li class="parentMenu">Home
<ul class="sub-menu">
<a href="mommymadness.php">
<li>This Mommy's Madness</li>
</a>
<a href="about.php">
<li>About Mommy Info</li>
</a>
<a href="contact.php">
<li>Contact Mommy Info</li>
</a>
</ul>
</li>
</a>
<a href="pregnancysplash.php">
<li class="parentMenu">Pregnancy
<ul class="sub-menu">
<a href="ttc.php">
<li>Trying To Conceive</li>
</a>
<a href="fetaldev.php">
<li>Fetal Development</li>
</a>
<a href="genderpredictions.php">
<li>Gender Predictions</li>
</a>
<a href="labordelivery.php">
<li>Labor and Delivery</li>
</a>
</ul>
</li>
</a>
<a href="aabsplash.php">
<li class="parentMenu">All About Baby
<ul class="sub-menu">
<a href="advice.php">
<li>Advice</li>
</a>
<a href="guidelines.php">
<li>Guidelines</li>
</a>
<a href="milestones.php">
<li>Milestones</li>
</a>
<a href="learndev.php">
<li>Learning Development</li>
</a>
</ul>
</li>
</a>
<a href="healthsplash.php">
<li class="parentMenu">Health
<ul class="sub-menu">
<a href="pregnutrition.php">
<li>Pregnancy Nutrition</li>
</a>
<a href="breastfeeding.php">
<li>Breastfeeding</li>
</a>
<a href="formula.php">
<li>Formula Feeding</li>
</a>
<a href="toddlers.php">
<li>Toddler Nutrition</li>
</a>
<a href="preexercise.php">
<li>Prenatal Exercise</li>
</a>
<a href="postexercise.php">
<li>Postpartum Exercise</li>
</a>
<a href="organic.php">
<li>Organic DIY Health</li>
</a>
</ul>
</li>
</a>
<a href="partymommasplash.php">
<li class="parentMenu">Party Momma
<ul class="sub-menu">
<a href="pregann.php">
<li>Pregnancy Announcement</li>
</a>
<a href="genderreveal.php">
<li>Gender Reveal</li>
</a>
<a href="babyshower.php">
<li>Baby Shower</li>
</a>
<a href="birthann.php">
<li>Birth Announcement</li>
</a>
<a href="birthdays.php">
<li>Birthdays</li>
</a>
</ul>
</li>
</a>
<a href="stationssplash.php">
<li class="parentMenu">Stations
<ul class="sub-menu">
<a href="hospitalbag.php">
<li>Hospital Bag</li>
</a>
<a href="diaperbag.php">
<li>Diaper Bag</li>
</a>
<a href="changingstation.php">
<li>Changing Station</li>
</a>
<a href="babygear.php">
<li>Baby Gear</li>
</a>
</ul>
</li>
</a>
<a href="memorymarkerssplash.php">
<li class="parentMenu">Memory Markers
<ul class="sub-menu">
<a href="diymemories.php">
<li>Do It Yourself</li>
</a>
<a href="purchasable.php">
<li>Buy It</li>
</a>
</ul>
</li>
</a>
<a href="reviewsplash.php">
<li class="parentMenu">Reviews
<ul class="sub-menu">
<a href="games.php">
<li>Games</li>
</a>
<a href="gear.php">
<li>Gear</li>
</a>
<a href="learning.php">
<li>Learning</li>
</a>
</ul>
</li>
</a>
<a href="mommymadness.php">
<li class="parentMenu">Blog
</li>
</a>
</ul>
<?php include_once ("header2.php"); ?>
</nav>
</header>
<!-- Header2.php -->
<div id="handle">
<p>☰Menu</p>
<ul id="navSmall">
<li class="parentMenuSmall">Home
<ul class="sub-menu-small">
<a href="index.php">
<li>Home</li>
</a>
<a href="about.php">
<li>About</li>
</a>
<a href="contact.php">
<li>Contact</li>
</a>
<a href="mommymadness.php">
<li>Mommy Madness</li>
</a>
</ul>
</li>
<li class="parentMenuSmall">Pregnancy
<ul class="sub-menu-small">
<a href="pregnancysplash.php">
<li>Pregnancy</li>
</a>
<a href="ttc.php">
<li>Trying to Conceive</li>
</a>
<a href="fetaldev.php">
<li>Fetal Development</li>
</a>
<a href="genderpredictions.php">
<li>Gender Predictions</li>
</a>
<a href="labordelivery.php">
<li>Labor and Delivery</li>
</a>
</ul>
</li>
<li class="parentMenuSmall">All About Baby
<ul class="sub-menu-small">
<a href="aabsplash.php">
<li>All About Baby</li>
</a>
<a href="advice.php">
<li>Advice</li>
</a>
<a href="guidelines.php">
<li>Guidelines</li>
</a>
<a href="milestones.php">
<li>Milestones</li>
</a>
<a href="learndev.php">
<li>Learning Development</li>
</a>
</ul>
</li>
<li class="parentMenuSmall">Health
<ul class="sub-menu-small">
<a href="healthsplash.php">
<li>Health and Nutrition</li>
</a>
<a href="pregnutrition.php">
<li>Pregnancy Nutrition</li>
</a>
<a href="breastfeeding.php">
<li>Breastfeeding</li>
</a>
<a href="mommymadness.php">
<li>Formula Feeding</li>
</a>
<a href="toddlers.php">
<li>Toddler Nutrition</li>
</a>
<a href="preexercise.php">
<li>Prenatal Exercise</li>
</a>
<a href="postexercise.php">
<li>Postpartum Exercise</li>
</a>
<a href="organic.php">
<li>Organic DIY Health</li>
</a>
</ul>
</li>
<li class="parentMenuSmall">Party Momma
<ul class="sub-menu-small">
<a href="partymommasplash.php">
<li>Party Momma</li>
</a>
<a href="pregann.php">
<li>Pregnancy Announcement</li>
</a>
<a href="genderreveal.php">
<li>Gender Reveal</li>
</a>
<a href="babyshower.php">
<li>Baby Shower</li>
</a>
<a href="birthann.php">
<li>Birth Announcement</li>
</a>
<a href="birthdays.php">
<li>Birthdays</li>
</a>
</ul>
</li>
<li class="parentMenuSmall">Stations
<ul class="sub-menu-small">
<a href="stationssplash.php">
<li>Stations</li>
</a>
<a href="hospitalbag.php">
<li>Hospital Bag</li>
</a>
<a href="diaperbag.php">
<li>Diaper Bag</li>
</a>
<a href="changingstation.php">
<li>Changing Station</li>
</a>
<a href="babygear.php">
<li>Baby Gear</li>
</a>
</ul>
</li>
<li class="parentMenuSmall">Memory Markers
<ul class="sub-menu-small">
<a href="index.php">
<li>Memory Markers</li>
</a>
<a href="diymemories.php">
<li>Do It Yourself</li>
</a>
<a href="purchasable.php">
<li>Buy It</li>
</a>
</ul>
</li>
<li class="parentMenuSmall">Reviews
<ul class="sub-menu-small">
<a href="reviewsplash.php">
<li>Reviews</li>
</a>
<a href="games.php">
<li>Games</li>
</a>
<a href="gear.php">
<li>Gear</li>
</a>
<a href="learning.php">
<li>Learning</li>
</a>
</ul>
</li>
<li class="parentMenuSmall">Blog
<ul class="sub-menu-small">
<a href="mommymadness.php">
<li>This Mommy's Madness</li>
</a>
</ul>
</li>
</ul>
</div>
<section class="section" id="home">
<h2>Welcome to Mommy Info</h2>
<div>
Whether you've been there and done that, or you're coming in for your first stop, this is the site for you.
<p>
Visit the Pregnancy page to access all kinds of information relating to carrying your little one.
<br> Visit the All About Baby page to see all sorts of facts about how the baby is growing, advice about raising him or her, and how to encourage healthy development.
<br> Looking for help deciding how to feed your little one or how to stay fit, visit the Health page!
<br> Maybe you're looking for ideas to celebrate milestones in your baby's life, check out the Party Momma or Memory Markers tabs!
<br> Stressed about what to get for your baby? Visit the Stations or Reviews tabs!
<br> Finally, if you're just wanting to take a gander at the madness that is my life, visit my blog!
</p>
</div>
</section>
<aside class="section" id="about">
<h2>You're on the Home Page!</h2>
<ul class="nav">
<li>The Mommy Behind the Madness</li>
<li>About Mommy Info</li>
<li>Contact Mommy Info</li>
</ul>
<div class="hide" id="blogposts">
<h2>Recent Madness</h2>
<p>Five Months, and What Have I Done?!</p>
<p>Four Months, and What Do I Need?</p>
<p>Three Months, and Help! What's Happening!?</p>
<p>Two Months</p>
<p>It's Positive!</p>
</div>
</aside>
<script async defer src="//assets.pinterest.com/js/pinit.js"></script>
</body>
CSS
body {
color:#ADD8E6;
background-image:url(backgroundarrows.png);
font-family:"Monotype Corsiva", sans-serif;
margin:0;
padding:0;
}
/* Global */
ul{
list-style-type: none;
margin: 0;
padding: 0;
}
a{
text-decoration: none;
color:#737597;
;
}
.section {
background-color:#fafbff;
border:thin solid #D3D3D3;
border-radius:10px;
box-shadow:lightgray 5px 5px 5px;
color:#696969;
display:inline;
float:left;
width:60%;
margin:0 1% 1%;
padding:5px 8px;
}
.section h2 {
border-bottom:solid medium #90cdd0;
color:#90cdd0;
text-align:center;
}
#about {
color:dimgrey;
float:right;
font-size:medium;
margin:1% 1% 0;
text-align:center;
width:33%;
}
.nav li {
text-align:left;
font-size:large;
padding:1%;
}
.nav a {
text-decoration:none;
color:darkgrey;
}
#home {
margin:1% 0 1% 1%;
}
#home div {
font-size:20px;
line-height:30px;
padding:1% 3%;
text-align:center;
}
#home div p{
font-family:"Times New Roman", serif;
font-size:20px;
line-height: 30px;
text-align:left;
}
.hide {
display: none;
}
/* Header */
header {
background-color:#cff1ff;
height:60px;
padding:5px 0;
}
header h1 {
color:#809dc6;
display:inline;
font-family:"Monotype Corsiva", sans-serif;
font-size:45px;
height:50px;
padding:5px 15px;
}
/*Website Navigation */
.navMenu {
display:inline;
font-size:20px;
}
.navMenu .parentMenu {
background-color:#cff1ff;
display:inline-block;
padding:5px 10px;
position:relative;
z-index:100000;
}
.navMenu .parentMenu:hover{
background-color:#bfd3ee;
}
.navMenu .parentMenu a{
color:#737597;
}
.navMenu .parentMenu:hover a:hover{
color:#87a2be;
}
.navMenu .parentMenu .sub-menu{
display:none;
left:0;
padding:0;
position:absolute;
top:33px;
width:180px;
z-index:10000;
}
.navMenu .parentMenu:hover .sub-menu{
display:block;
white-space:nowrap;
}
.navMenu .parentMenu:hover .sub-menu li{
background-color:#bfd3ee;
font-size:17px;
padding:10px;
text-align:left;
white-space:nowrap;
width:100%;
z-index:10000;
}
.navMenu .parentMenu .sub-menu li:hover{
background-color:#9ac9ed;
}
#handle{
font-size: 20px;
display: none;
color: #87a2be;
float: left;
width: 100%;
text-align: left;
}
#navSmall {
display: none;
text-align: center;
background-color: #cff1ff;
height: 100%;
}
#handle:hover #navSmall {
display: inline;
}
.sub-menu-small{
display: none;
background-color: #9ac9ed;
position: relative;
}
.sub-menu-small li {
border-bottom: solid thin #809dc6;
padding:1px 3px;
}
#navSmall .parentMenuSmall {
background-color: inherit;
text-align: left;
padding: 15px;
border-bottom: solid thin #809dc6;
font-size: 18px;
}
#navSmall .parentMenuSmall:hover .sub-menu-small {
display: inline-block;
margin-left: 100px;
position: absolute;
}
#construct {
width: 100%;
height: 100%;
margin-top: 100px;
border-radius: 20%;
}
/* Media Queries */
/*tablet*/
/*remove floats */
#media(max-width: 768px) {
body{
width: 100%;
}
header {
float: none;
text-align: center;
width: 100%;
height: 120px;
}
.section{
width: 95%;
}
#about{
display: none;
}
#handle{
display: block;
}
.navMenu {
display: none;
}
}
/* Tables on Diaper Bag*/
table {
width: 100%;
text-align: center;
}
table th {
font-size: 28px;
}
table td {
font-size: 15px;
font-family: "Comic Sans MS", sans-serif;
font-weight: bold;
}
#main {
color: #66CDAA;
}
#quick {
color: #809dc6;
}
#car {
color: #95b6c0;
}
#item, .item {
color: #9c9c9c;
}
.mainBag {
background-color: rgba(102, 205, 170, 0.1);
}
.toiletries {
background-color: rgba(128, 157, 198, 0.1);
}
.firstAid {
background-color: rgba(149, 182, 192, 0.1);
}
table td {
border: solid thin gray;
border-top:none;
border-right: none;
}
.right {
background-color: palegreen;
}
.wrong {
background-color: #ffc5b7;
}
.girl {
background-color: lightpink;
}
.boy {
background-color: lightblue;
}
.section p {
font-family: "Times New Roman", serif;
}
.items {
font-size: 20px;
font-family: "Times New Roman", serif;
color: #95b6c0;
}
.itemDesc{
font-size: 18px;
color: #6b6b6b;
}

Can't Fix The hover of my Navbar

I could't fix the hover of my nav bar to fulrange the hole Square on my Li elements,here is my code so you can understand me ,Please help.
I could't fix the hover of my nav bar to fulrange the hole Square on my Li elements,here is my code so you can understand me ,Please help.
https://jsfiddle.net/h41zhwrx/
<body>
<!** Social Media Icons**>
<div class='social-wrap'>
<ul>
<li><a class='facebook1' href='http://www.facebook.com/username' target='_blank' title='Facebook' rel='nofollow'></a></li>
<li><a class='twitter1' href='http://twitter.com/username' target='_blank' title='Twitter' rel='nofollow'></a></li>
<li><a class='google-p1' href='https://plus.google.com/b/username' target='_blank' title='Google Plus' rel='nofollow'></a></li>
<li><a class='rss1' href='http://feeds.feedburner.com/username' target='_blaank' title='RSS Feed' rel='nofollow'></a></li>
<li><a class='pinit1' href='http://www.pinterest.com/username' target='_blank' title='Pinterest' rel='nofollow'></a></li>
<li><a class='linkdin1' href='http://www.linkedin.com/in/username' target='_blank' title='Linkedin' rel='nofollow'></a></li>
</ul>
</div>
<!**my top bar space**>
<ul class="topnav" id="myTopnav">
<li>
</li>
<li class="icon">
</li>
</ul>
<div class="banner">
<img class="banner-image" src="img/banner.jpg" alt="Make Image responsive" >
</div>
<!** My nav bar space**>
<ul class="nav">
<li class="icon">
☰
</li>
<li> DIGITAL </li>
<li> ANALYSES </li>
<li> CRÉATIVITÉ </li>
<li> TECHNOLOGIE </li>
<li> ÉVÉNEMENT </li>
<li> EMPLOI </li>
<li> CONTACT </li>
</ul>
<div class="footer">Dzair Tic Tous droits réservés ©2017.</div>
</body>
.nav {
font-family: 'arial', serif;
margin-top: 0;
background-color: #1f5d86;
Color: #ffffff;
list-style: none; /* Na7i boutton ta3 la liste */
text-align: center;
opacity: 0.9;
}
.nav > li {
display: inline-block;
padding: 15px 20px;
font-size: auto ;
}
Just replace these 2 classes in css