Dropdown of Navbar goes behind image slider - html

My dropdown menu goes behind the image slider part of my website. How can I get the dropdown in front of the image slider? I have also some other div's but they go like normally behind the dropdown menu of the Navbar. So I like to have the dropdown in front of the div of the image slider I made. I hope someone can help me
<--code html-->
<nav>
<div class="logo">
<div id="myMenu">
<div class="logo-navbar">
<nav>
<img src="images/logo-groot.png" height="80" />
</nav>
</div>
</div>
</div>
<label for="btn" class="icon">
<span class="fa fa-bars"></span>
</label>
<input type="checkbox" id="btn">
<ul>
<li>Home</li>
<li>
<label for="btn-2" class="show">Assortiment</label>
Assortiment
<input type="checkbox" id="btn-2">
<ul>
<li>Knalvuurwerk</li>
<li>Siervuurwerk</li>
<li>Kindervuurwerk</li>
</ul>
</li>
<li>Contact</li>
</ul>
</nav>
<div class="container">
<h1 id="headline">Nog <span id="days"></span> dagen tot start online vuurwerkverkoop</h1
<div id="countdown">
</div>
</div>
<div class="slideshow-container">
<!-- Full-width images with number and caption text -->
<div class="mySlides fade">
<a href="selectie.html"><img src="images/pyropapel-actie.png" style="width:100%">
</div>
<div class="mySlides fade">
<a href="contact.html"><img src="images/logo-groot.png" style="width:100%">
</div>
<div class="mySlides fade">
<a href="geschiedenis.html"><img src="images/logo-groot.png" style="width:100%">
</div>
<!-- Next and previous buttons -->
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</a>
</div>
<br>
<!-- The dots/circles -->
<div class="dots" style="text-align:center">
<span class="dot" onclick="currentSlide(1)"></span>
<span class="dot" onclick="currentSlide(2)"></span>
<span class="dot" onclick="currentSlide(3)"></span>
</div>
</div>
<-- css -->
nav{
background: #151515;
}
nav:after{
content: '';
clear: both;
display: table;
}
nav .logo{
float: left;
line-height: 70px;
padding-left: 60px;
}
nav ul{
float: right;
margin-right: 4px;
list-style: none;
position: relative;
}
nav ul li{
float: left;
display: inline-block;
background: #151515;
margin: 5 5px;
}
nav ul li a{
color: white;
line-height: 70px;
text-decoration: none;
font-size: 18px;
padding: 8px 15px;
}
nav ul li a:hover{
color: white;
border-radius: 5px;
box-shadow: 0 0 5px #000000,
0 0 10px #0a0a0a;
}
nav ul ul li a:hover{
box-shadow: none;
}
nav ul ul{
position: absolute;
top: 90px;
border-top: 3px solid red;
opacity: 0;
visibility: hidden;
transition: top .3s;
}
nav ul ul ul{
border-top: none;
}
nav ul li:hover > ul{
top: 70px;
opacity: 1;
visibility: visible;
}
nav ul ul li{
position: relative;
margin: 0px -20px;
width: 175px;
float: none;
display: list-item;
border-bottom: 1px solid rgba(0,0,0,0.3);
text-align:center;
}
nav ul ul li a{
line-height: 50px;
}
nav ul ul ul li{
position: relative;
top: -60px;
left: 150px;
}
.show,.icon,input{
display: none;
}
.fa-plus{
font-size: 15px;
margin-left: 40px;
}
#media all and (max-width: 968px) {
nav ul{
margin-right: 0px;
float: left;
}
nav .logo{
padding-left: 30px;
width: 100%;
}
.show + a, nav > ul{
display: none;
}
nav ul li,nav ul ul li{
display: block;
width: 100%;
}
nav ul li a:hover{
box-shadow: none;
}
.show{
display: block;
color: white;
font-size: 18px;
padding: 0 15px;
line-height: 70px;
cursor: pointer;
}
.show:hover{
color: white;
border-radius:5px;
}
.icon{
display: block;
color: white;
position: absolute;
top: 25;
right: 40px;
line-height: 70px;
cursor: pointer;
font-size: 25px;
}
nav ul ul{
top: 70px;
border-top: 0px;
float: none;
position: static;
display: none;
opacity: 1;
visibility: visible;
}
nav ul ul a{
padding-left: 40px;
}
nav ul ul ul a{
padding-left: 80px;
}
nav ul ul ul li{
position: static;
}
[id^=btn]:checked + ul{
display: block;
}
nav ul ul li{
border-bottom: 0px;
}
span.cancel:before{
content: '\f00d';
}
}
.slideshow-container {
position: relative;
margin: auto;
background-color: rgba(0, 0, 0, 1);
width:75%;
}
/* Hide the images by default */
.mySlides {
display: none;
}
/* Next & previous buttons */
.prev, .next {
cursor: pointer;
position: absolute;
align-items: center;
top: 50%;
width:auto;
margin-top: -22px;
padding: 16px;
color: white;
font-weight: bold;
font-size: 18px;
transition: 0.6s ease;
border-radius: 0 3px 3px 0;
user-select: none;
}
/* Position the "next button" to the right */
.next {
right: 0;
border-radius: 3px 0 0 3px;
}
/* On hover, add a black background color with a little bit see-through */
.prev:hover, .next:hover {
background-color: rgba(0,0,0,0.8);
}
/* Caption text */
.text {
color: #f2f2f2;
font-size: 15px;
padding: 8px 12px;
position: absolute;
bottom: 8px;
width: 100%;
text-align: center;
}
/* Number text (1/3 etc) */
.numbertext {
color: #f2f2f2;
font-size: 12px;
padding: 8px 12px;
position: absolute;
top: 0;
}
/* The dots/bullets/indicators */
.dot {
cursor: pointer;
height: 15px;
width: 15px;
margin: 0 2px;
border-radius: 50%;
display: inline-block;
transition: background-color 0.6s ease;
background-color: #bbb;
}
.active, .dot:hover {
background-color: #717171;
}
.dots{
background-color: rgba(23, 14, 13, 0.97);
width:75%;
align-items:center;
margin:auto;
padding-top: 20px;
margin-top:-24px;
}
/* Fading animation */
.fade {
-webkit-animation-name: fade;
-webkit-animation-duration: 1.5s;
animation-name: fade;
animation-duration: 1.5s;
}
#-webkit-keyframes fade {
from {opacity: .4}
to {opacity: 1}
}
#keyframes fade {
from {opacity: .4}
to {opacity: 1}
}

Related

Navbar List Items not showing and Navbar not sticking to the top

I have my navbar and I have 2 issues. Though it seems to be responsive there's 2 issues. 1. between 968px and about 2001px the list items dont show when clicked or hovered. After around 2000px the list items show. Issue 2. I want the navbar to stick to the top of the page when scrolling down. I tried messing with the positioning but nothing was working for me . this is my code
* {
margin: 0;
padding: 0;
}
nav{
background: #1b1b1b;
display:flex;
justify-content:space-around;
}
nav:after{
content: '';
clear: both;
display: table;
}
nav .logo{
color: white;
font-size: 27px;
font-weight: 600;
line-height: 70px;
padding-left: 60px;
}
nav ul{
float: right;
margin-right: 40px;
list-style: none;
position: relative;
}
nav ul li{
display: inline-block;
background: #1b1b1b;
margin: 0 5px;
}
nav ul li a{
color: white;
line-height: 70px;
text-decoration: none;
font-size: 18px;
padding: 8px 15px;
}
nav ul li a:hover{
color: cyan;
border-radius: 5px;
box-shadow: 0 0 5px #33ffff,
0 0 10px #66ffff;
}
nav ul ul li a:hover{
box-shadow: none;
}
nav ul ul{
position: absolute;
top: 90px;
border-top: 3px solid cyan;
opacity: 0;
visibility: hidden;
transition: top .3s;
}
nav ul ul ul{
border-top: none;
}
nav ul li:hover > ul{
top: 70px;
opacity: 1;
visibility: visible;
}
nav ul ul li{
position: relative;
margin: 0px;
width: 150px;
float: none;
display: list-item;
border-bottom: 1px solid rgba(0,0,0,0.3);
}
nav ul ul li a{
line-height: 50px;
}
nav ul ul ul li{
position: relative;
top: -60px;
left: 150px;
}
.show,.icon,input{
display: none;
}
.fa-plus{
font-size: 15px;
margin-left: 40px;
}
#media all and (max-width: 968px) {
nav ul{
margin-right: 0px;
float: left;
}
nav .logo{
padding-left: 30px;
width: 100%;
}
.show + a, ul{
display: none;
}
nav ul li,nav ul ul li{
display: block;
width: 100%;
}
nav ul li a:hover{
box-shadow: none;
}
.show{
display: block;
color: white;
font-size: 18px;
padding: 0 20px;
line-height: 70px;
cursor: pointer;
}
.show:hover{
color: cyan;
}
.icon{
display: block;
color: white;
position: absolute;
top: 0;
right: 40px;
line-height: 70px;
cursor: pointer;
font-size: 25px;
}
nav ul ul{
top: 70px;
border-top: 0px;
float: none;
position: static;
display: none;
opacity: 1;
visibility: visible;
}
nav ul ul a{
padding-left: 40px;
}
nav ul ul ul a{
padding-left: 80px;
}
nav ul ul ul li{
position: static;
}
[id^=btn]:checked + ul{
display: block;
}
nav ul ul li{
border-bottom: 0px;
}
span.cancel:before{
content: '\f00d';
}
}
.content{
z-index: -1;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
text-align: center;
}
header{
font-size: 35px;
font-weight: 600;
padding: 10px 0;
}
p{
font-size: 30px;
font-weight: 500;
}
<div>
<nav>
<div class="logo">
Davids Nav</div>
<label for="btn" class="icon">
<span class="fa fa-bars"></span>
</label>
<input type="checkbox" id="btn">
<ul>
<li>Home</li>
<li>
<label for="btn-1" class="show">Features +</label>
Features
<input type="checkbox" id="btn-1">
<ul>
<li>Pages</li>
<li>Elements</li>
<li>Icons</li>
</ul>
</li>
<li>
<label for="btn-2" class="show">Services +</label>
Services
<input type="checkbox" id="btn-2">
<ul>
<li>Web Design</li>
<li>App Design</li>
<li>
<label for="btn-3" class="show">More +</label>
More <span class="fa fa-plus"></span>
<input type="checkbox" id="btn-3">
<ul>
<li>Submenu-1</li>
<li>Submenu-2</li>
<li>Submenu-3</li>
</ul>
</li>
</ul>
</li>
<li>Portfolio</li>
<li>Contact</li>
</ul>
</nav>
</div>
On my browser at 969px viewport width, a media query is causing the <ul> to be hidden. I updated that query and added another one at 700px. You can work on finishing the rest of the media queries for a fully responsive nav.
Next, in order to have the navbar always stick to the top of the viewport while scrolling, add position: fixed along with top: 0
Try this out.
* {
margin: 0;
padding: 0;
}
nav {
position: fixed;
width: 100%;
top: 0;
background: #1b1b1b;
display:flex;
justify-content:space-around;
}
nav:after {
content: '';
clear: both;
display: table;
}
nav .logo{
color: white;
font-size: 27px;
font-weight: 600;
line-height: 70px;
padding-left: 60px;
}
nav ul{
float: right;
margin-right: 40px;
list-style: none;
position: relative;
}
nav ul li{
display: inline-block;
background: #1b1b1b;
margin: 0 5px;
}
nav ul li a{
color: white;
line-height: 70px;
text-decoration: none;
font-size: 18px;
padding: 8px 15px;
}
nav ul li a:hover{
color: cyan;
border-radius: 5px;
box-shadow: 0 0 5px #33ffff,
0 0 10px #66ffff;
}
nav ul ul li a:hover{
box-shadow: none;
}
nav ul ul{
position: absolute;
top: 90px;
border-top: 3px solid cyan;
opacity: 0;
visibility: hidden;
transition: top .3s;
}
nav ul ul ul{
border-top: none;
}
nav ul li:hover > ul{
top: 70px;
opacity: 1;
visibility: visible;
}
nav ul ul li{
position: relative;
margin: 0px;
width: 150px;
float: none;
display: list-item;
border-bottom: 1px solid rgba(0,0,0,0.3);
}
nav ul ul li a{
line-height: 50px;
}
nav ul ul ul li{
position: relative;
top: -60px;
left: 150px;
}
.show,.icon,input{
display: none;
}
.fa-plus{
font-size: 15px;
margin-left: 40px;
}
#media all and (max-width: 968px) {
nav ul {
display: flex;
font-size: 1rem;
}
nav .logo{
padding-left: 30px;
width: 100%;
}
.show + a, ul{
display: none;
}
nav ul li,nav ul ul li{
display: block;
width: 100%;
}
nav ul li a:hover{
box-shadow: none;
}
.show{
display: block;
color: white;
font-size: 18px;
padding: 0 20px;
cursor: pointer;
}
.show:hover{
color: cyan;
}
.icon{
display: block;
color: white;
position: absolute;
top: 0;
right: 40px;
line-height: 70px;
cursor: pointer;
font-size: 25px;
}
nav ul ul{
top: 70px;
border-top: 0px;
float: none;
position: static;
display: none;
opacity: 1;
visibility: visible;
}
nav ul ul a{
padding-left: 40px;
}
nav ul ul ul a{
padding-left: 80px;
}
nav ul ul ul li{
position: static;
}
[id^=btn]:checked + ul{
display: block;
}
nav ul ul li{
border-bottom: 0px;
}
span.cancel:before{
content: '\f00d';
}
}
.content{
z-index: -1;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
text-align: center;
}
header{
font-size: 35px;
font-weight: 600;
padding: 10px 0;
}
p{
font-size: 30px;
font-weight: 500;
}
#media only screen and (max-width: 700px) {
nav {
display: flex;
justify-content: center;
align-items: center;
}
nav .logo {
line-height: 40px;
}
}
<div>
<nav>
<div class="logo">
Davids Nav</div>
<label for="btn" class="icon">
<span class="fa fa-bars"></span>
</label>
<input type="checkbox" id="btn">
<ul>
<li>Home</li>
<li>
<label for="btn-1" class="show">Features +</label>
Features
<input type="checkbox" id="btn-1">
<ul>
<li>Pages</li>
<li>Elements</li>
<li>Icons</li>
</ul>
</li>
<li>
<label for="btn-2" class="show">Services +</label>
Services
<input type="checkbox" id="btn-2">
<ul>
<li>Web Design</li>
<li>App Design</li>
<li>
<label for="btn-3" class="show">More +</label>
More <span class="fa fa-plus"></span>
<input type="checkbox" id="btn-3">
<ul>
<li>Submenu-1</li>
<li>Submenu-2</li>
<li>Submenu-3</li>
</ul>
</li>
</ul>
</li>
<li>Portfolio</li>
<li>Contact</li>
</ul>
</nav>
</div>

CSS - Problem with visibility: hidden; on Dropmenu

ul.ulDropMenu{
z-index: 2;
}
ul.ulDropMenu li{
list-style: none;
position: relative;
}
ul.ulDropMenu li ul li a:hover{
color: #ff003c;
}
ul.ulDropMenu li a{
display: block;
padding: 9px 14px;
}
ul.ulDropMenu li ul{
position: absolute;
background-color: #fff;
border-radius: 4px;
padding: 8px;
}
nav ul li ul{
visibility: hidden;
display: block;
}
ul.ulDropMenu li:hover ul{
max-height: 290px;
visibility: visible;
opacity: 1;
}
ul.ulDropMenu li ul li{
width: 135px;
}
ul.ulDropMenu li ul li a{
padding: 6px 14px;
color: #2A2A2A;
}
.navBar {
background-color: #2A2A2A;
min-width: 100%;
}
.wrapper {
max-width: 100%;
padding: 0 10px;
-webkit-box-shadow: 0px 2px 7px 3px #8C8C8C;
-moz-box-shadow: 0px 2px 7px 3px #8C8C8C;
box-shadow: 0px 2px 7px 3px #8C8C8C;
padding-top: 3px;
}
nav ul {
display: flex;
justify-content: space-between;
list-style-type: none;
padding-top: 15px;
}
nav ul a {
color: #7f7f7f;
text-decoration: none;
transition: color .4s ease;
font-size: 18px;
}
nav ul li ul li a{
font-size: 15px;
}
nav ul a:hover {
color: #afafaf;
}
nav li {
display: inline-block;
}
nav #menu-toggle {
display: none;
}
nav .label-toggle {
display: none;
}
nav .wrapper {
align-items: center;
display: flex;
}
#media screen and (max-width: 992px) {
nav nav ul li ul li {
color: #7f7f7f;
padding-right: 20px;
}
nav ul {
display: block;
height: 0;
list-style-type: none;
opacity: 0;
text-align: left;
padding-left: 0;
transition: all 1s ease;
width: 50%;
visibility: hidden;
}
nav li {
color: #53354A;
display: block;
font-size: 19px;
}
nav #menu-toggle:checked ~ ul {
opacity: 1;
height: 62vh;
visibility: visible;
}
nav .label-toggle {
background: linear-gradient(to bottom, #fff 0%, #fff 20%, transparent 20%, transparent 40%, #fff 40%, #fff 60%, transparent 60%, transparent 80%, #fff 80%, #fff 100%);
cursor: pointer;
display: block;
float: right;
height: 35px;
margin-top: 35px;
width: 35px;
}
nav .wrapper {
display: block;
}
}
<nav class="navBar">
<nav class="wrapper">
<img width="215" height="85" src="https://www.dsgfs.com/wp-content/uploads/2015/09/Test-Logo-250x60.png" alt="">
<input type="checkbox" id="menu-toggle" />
<label for="menu-toggle" class="label-toggle"></label>
<ul class="ulDropMenu">
<li>
Menu 1
</li>
<li>
<a href="#">Menu 2
<i class="fa fa-caret-down"></i>
</a>
<ul>
<li>
1
</li>
<li>
2
</li>
</ul>
</li>
<li>
<a href="#">Menu 3
<i class="fa fa-caret-down"></i>
</a>
<ul>
<li>
<i class="fab fa-facebook-square"></i> Facebook
<i class="fab fa-twitter-square"></i> Twitter
<i class="fab fa-instagram"></i> Instagram
</li>
</ul>
</li>
</ul>
</nav>
</nav>
Click on "Run code snipped" and on "full page" to see the snipped, and resize the screen under 992px.
The problem begins when i resize the screen under 992px. The navbar get bigger on the bottom, and the dropmenu don't open, i thought that it maybe was by the fault of the display: block but i don't think it is. I made some tests here and i realized that this problem was caused by this line:
nav ul {
display: block;
height: 0;
list-style-type: none;
opacity: 0;
text-align: left;
padding-left: 0;
transition: all 1s ease;
width: 50%;
visibility: hidden; //This line
}
But if i take out the visibility: hidden; my collapisable menu will not work.
How can i fix it?
You css is very messed up. You have unwanted space on navbar because ul.ulDropMenu is always visible and it has padding-top: 15px inherited from .nav ul and margins inherited from default browser settings.
I suggest you read first about resets
/* basic reset for all elements */
* {
margin: 0;
padding: 0;
border: 0;
}
ul.ulDropMenu{
z-index: 2;
padding: 0; /* override padding set by '.nav ul' */
}
ul.ulDropMenu li{
list-style: none;
position: relative;
}
ul.ulDropMenu li ul li a:hover{
color: #ff003c;
}
ul.ulDropMenu li a{
display: block;
padding: 9px 14px;
}
ul.ulDropMenu li ul{
position: absolute;
background-color: #fff;
border-radius: 4px;
padding: 8px;
height: auto; /* override height set in '.nav ul' */
}
nav ul li ul{
visibility: hidden;
display: block;
}
ul.ulDropMenu li:hover ul{
max-height: 290px;
visibility: visible;
opacity: 1;
z-index: 1;
}
ul.ulDropMenu li ul li{
width: 135px;
}
ul.ulDropMenu li ul li a{
padding: 6px 14px;
color: #2A2A2A;
}
.navBar {
background-color: #2A2A2A;
min-width: 100%;
}
.wrapper {
max-width: 100%;
padding: 0 10px;
-webkit-box-shadow: 0px 2px 7px 3px #8C8C8C;
-moz-box-shadow: 0px 2px 7px 3px #8C8C8C;
box-shadow: 0px 2px 7px 3px #8C8C8C;
padding-top: 3px;
}
nav ul {
display: flex;
justify-content: space-between;
list-style-type: none;
padding-top: 15px;
}
nav ul a {
color: #7f7f7f;
text-decoration: none;
transition: color .4s ease;
font-size: 18px;
}
nav ul li ul li a{
font-size: 15px;
}
nav ul a:hover {
color: #afafaf;
}
nav li {
display: inline-block;
}
nav #menu-toggle {
display: none;
}
nav .label-toggle {
display: none;
}
nav .wrapper {
align-items: center;
display: flex;
}
#media screen and (max-width: 992px) {
nav nav ul li ul li {
color: #7f7f7f;
padding-right: 20px;
}
nav ul {
display: block;
height: 0;
list-style-type: none;
opacity: 0;
text-align: left;
padding-left: 0;
transition: all 1s ease;
width: 50%;
visibility: hidden;
}
nav li {
color: #53354A;
display: block;
font-size: 19px;
}
nav #menu-toggle:checked ~ ul {
opacity: 1;
height: 62vh;
visibility: visible;
}
nav .label-toggle {
background: linear-gradient(to bottom, #fff 0%, #fff 20%, transparent 20%, transparent 40%, #fff 40%, #fff 60%, transparent 60%, transparent 80%, #fff 80%, #fff 100%);
cursor: pointer;
display: block;
float: right;
height: 35px;
margin-top: 35px;
width: 35px;
}
nav .wrapper {
display: block;
}
}
<nav class="navBar">
<nav class="wrapper">
<img width="215" height="85" src="https://www.dsgfs.com/wp-content/uploads/2015/09/Test-Logo-250x60.png" alt="">
<input type="checkbox" id="menu-toggle" />
<label for="menu-toggle" class="label-toggle"></label>
<ul class="ulDropMenu">
<li>
Menu 1
</li>
<li>
<a href="#">Menu 2
<i class="fa fa-caret-down"></i>
</a>
<ul>
<li>
1
</li>
<li>
2
</li>
</ul>
</li>
<li>
<a href="#">Menu 3
<i class="fa fa-caret-down"></i>
</a>
<ul>
<li>
<i class="fab fa-facebook-square"></i> Facebook
<i class="fab fa-twitter-square"></i> Twitter
<i class="fab fa-instagram"></i> Instagram
</li>
</ul>
</li>
</ul>
</nav>
</nav>

Why wont my nav display dropdown-links vertically?

I have been sitting for 4 hours now trying to make my nav display dropdown-links vetically but it continues to show them horizontally instead. I can´t figure out why this is happening or how to fix it.
I would appreciate it very much if some kind soul could tell me what I am doing wrong. I have a sneaking suspecion this is caused due to my settings for the nav (it changes size at a certain width) but I am not sure...
I have ripped my nav from my website and thrown everything into codepen, but even after several attempts to figure out where the problem starts - nothing! It displays "link1" right below and then just adds "link2" and "link3" to the right of it, instead of under
Please help?
Codepen: https://codepen.io/Pinchofginger/pen/BJJQgZ
If there are any oddities in the CSS it´s because I have a dropdown menu for mobile that display when you press an icon... it is not currently working either, but that a question for another time.
My HTML
<header class="mainheader">
<section id="baggrund">
<div id="mainlogo">
Sønderborg
<p> og omegns</p> Kattelaug<br />
<img class="vector" src="billeder/udklip.png" alt="Kattesilhuet"></div>
<nav>
<input type="checkbox" id="menu-checkbox" role="button" />
<label for="menu-checkbox" id="menu-button">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</label>
<div id="nav_wrap">
<ul id="menu">
<li>Forside</li>
<li>Adopter en kat</li>
<li>Tilløber katte</li>
<li> Kattens pleje</li>
<li class="dropdown">
<a href="javascript:void(0)" class="dropbtn">
Kontakt</a><div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</li>
</ul></div>
</nav>
</section>
</header>
MY CSS
/* small nav */
#media screen and (max-width: 61em) {
#menu li {
width: 20%;
}
#menu li a {
font-size: 0.9em;
width:100%;
color:red;}
#menu ul {width:100%;}
/*sidebar*/
body#index .sidemenu .sidebar1 {padding: 0 0 0 0;}
body#index #Mega {width: 96%; height:80px;}
body#index .sidemenu .sidebar1 h3 {font-size: 0.9em;}
}
/* stor nav*/
#media screen and (min-width: 61em) {
#menu li {
width: 20%;
}
#menu li a {
font-size: 1.2em;
width:100%;
color: #505050;
}} /*slut, stor*/
#menu li {
display: inline-block;
background: none;
padding: 5px 5px 5px 5px;
}
#menu li a {
text-transform: uppercase;
transition: all .5s ease;
text-decoration: none;
text-align: center;
line-height: 55px;
display: inline-block;}
.sidemenu .pleje {font-size: 0.9em; display:inline-block }
.sidemenu .pleje h3 {color: orange;}
#mainlogo {
display: block;
}
.mainheader {
width: 100%;
}
#bannerkat { display: none;}
#menu-button { display: none;}
#menu {
display: block;
border-radius: 0;
text-align: center;
position: relative;
}
/* Navigations menuen (links osv) */
#nav_wrap {
background: #f9f4ea;
width: 100%;
white-space: nowrap;
float: left;
height: 60px;
position: relative;
margin-top: 144px;
bottom: 0;
/* overflox:hidden; */
z-index: 9999;
opacity: .9;
box-shadow: 0px 1px 4px beige;
padding: 0;
}
li a, .dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover, .dropdown:hover .dropbtn {
background-color: red;
}
li.dropdown {
display: inline-block;
}
.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 {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown-content a:hover {background-color: #f1f1f1}
.dropdown:hover .dropdown-content {
display: block;
}
/* højde for billed-sektion*/
.mainheader section {
min-height: 204px;
}
#mainlogo {
font-size: 37px;
color: white;
border: 7px solid white;
display: inline-block;
padding: 10px;
position: absolute;
height: 123px;
/* hvid boks*/
line-height: 25px;
top: 202px;
margin-top: -180px;
left: 50%;
width: 600px;
text-align: center;
margin-left: -300px;
text-shadow: 1px 2px 1px #000;
box-shadow: 1px 2px 1px #000;
}
/* og omegns */
#mainlogo p {
font-size: 20px;
padding: 5px;
}
.vector {
width: 60px;
margin-left: -450px;
margin-top: -36px;
}
.mainheader {
margin-top: 10px;
}
Change line 42 in css: "menu li a" to Display: block instead of Display: inline-block:
#menu li a {
text-transform: uppercase;
transition: all .5s ease;
text-decoration: none;
text-align: center;
line-height: 55px;
display: block;
}

navigation submenu showing up before hovering parent

I have a horizontal nav bar and I set the submenu to show only when you hover over the parent but the submenus show up when I move my mouse even a couple inches below the parents. I'm not sure how to fix that.
HTML:
<body>
<header>
<div class="nav">
<ul class="mainmenu">
<li>Home</li>
<li>Photography
<ul class="submenu">
<li>Belize</li>
<li>Fernie BC</li>
<li>Montana</li>
<li>Philippines</li>
<li>Lake Tahoe</li>
<li>The Kids</li>
</ul>
</li>
<li>Woodworking
<ul class="submenu">
<li>Furniture</li>
<li>Cutting Boards</li>
<li>Bandsaw Boxes</li>
<li>Keepsake Boxes</li>
<li>Odds &amp Ends</li>
</ul>
<li>About</li>
<li>Contact</li>
</ul>
</div>
</header>
</body>
</html>
CSS:
body {
background-color: rgb(51,51,51);
color: white;
}
.nav > ul {
list-style: none;
background-color: rgba(0, 0, 0, 0.6);
text-align: center;
padding: 10px;
width: 100%;
}
.nav > li {
width: 230px;
border-bottom: none;
height: 50px;
line-height: 40px;
display: inline-block;
margin-right: -4px;
}
.nav > ul > li {
list-style-type: none;
display:inline-block;
padding: 5px 35px 5px 35px;
position: relative;
text-align: left;
line-height: 40px;
font-size: 25px;
}
.nav > ul > li:hover {
background-color: #009933;
}
ul.submenu {
position: absolute;
background-color: #141414;
list-style-type: none;
width: 190px;
padding-left: 0px;
padding-top: 5px;
padding-right: 60px;
margin-top: 15px;
margin-left: -35px;
opacity: 0;
}
ul.submenu li {
padding-left: 25px;
padding-top: 5px;
padding-bottom: 5px;
}
.nav li:hover .submenu {
opacity: 1;
}
ul.submenu li:hover {
color: white;
}
.nav a {
text-decoration: none;
color: white;
display: block;
padding-left: 15px;
padding-right: 15px;
transition: .3s background-color;
}
.nav a:hover {
background-color: #009933;
color: black;
}
Will Advise adding the visibility property to be hidden on your "li" element. Opacity 0 still makes the "li" present and the "li" element extends with the submenu. See code below hope it helps.
body {
background-color: rgb(51,51,51);
color: white;
}
.nav > ul {
list-style: none;
background-color: rgba(0, 0, 0, 0.6);
text-align: center;
padding: 10px;
width: 100%;
}
.nav > li {
width: 230px;
border-bottom: none;
height: 50px;
line-height: 40px;
display: inline-block;
margin-right: -4px;
}
.nav > ul > li {
list-style-type: none;
display:inline-block;
padding: 5px 35px 5px 35px;
position: relative;
text-align: left;
line-height: 40px;
font-size: 25px;
}
.nav > ul > li:hover {
background-color: #009933;
}
ul.submenu {
position: absolute;
background-color: #141414;
list-style-type: none;
width: 190px;
padding-left: 0px;
padding-top: 5px;
padding-right: 60px;
margin-top: 15px;
margin-left: -35px;
opacity: 0;
visibility: hidden;
}
ul.submenu li {
padding-left: 25px;
padding-top: 5px;
padding-bottom: 5px;
}
.nav li:hover .submenu {
opacity: 1;
visibility: visible;
}
ul.submenu li:hover {
color: white;
}
.nav a {
text-decoration: none;
color: white;
display: block;
padding-left: 15px;
padding-right: 15px;
transition: .3s background-color;
}
.nav a:hover {
background-color: #009933;
color: black;
}
<body>
<header>
<div class="nav">
<ul class="mainmenu">
<li>Home</li>
<li>Photography
<ul class="submenu">
<li>Belize</li>
<li>Fernie BC</li>
<li>Montana</li>
<li>Philippines</li>
<li>Lake Tahoe</li>
<li>The Kids</li>
</ul>
</li>
<li>Woodworking
<ul class="submenu">
<li>Furniture</li>
<li>Cutting Boards</li>
<li>Bandsaw Boxes</li>
<li>Keepsake Boxes</li>
<li>Odds &amp Ends</li>
</ul>
<li>About</li>
<li>Contact</li>
</ul>
</div>
</header>
</body>
Update your css change margin-top: 15px to margin-top: 5px
Set display: none; when it is hidding, so hover below the nav menu will not trigger it.
ul.submenu {
position: absolute;
background-color: #141414;
list-style-type: none;
width: 190px;
padding-left: 0px;
padding-top: 5px;
padding-right: 60px;
margin-top: 5px;
margin-left: -35px;
opacity: 0;
display: none;
}
Add this to your .submenu so when it should show set to display:block;:
.nav li:hover .submenu {
opacity: 1;
display: block;
z-index: 9999;
}
Now, the solution:
/* ************************************* HOME PAGE **************************************** */
#homeImage {
background: url("fernielow.jpg");
background-repeat: no-repeat;
background-size: cover;
font-family: 'Oswald', sans-serif;
color: white;
letter-spacing: 2px;
}
h1 {
background-color: rgba(0, 0, 0, 0.6);
text-align: center;
padding: 10px;
width: 99%;
margin-top: 450px;
}
h1 a {
text-decoration: none;
}
h1 a:visited {
text-decoration: none;
color: white;
}
h1 a:hover {
background-color: #009933;
padding: 10px 20px 10px 20px;
color: black;
}
h1 a:active {
text-decoration: underline;
}
/* ************************************* NAVIGATION **************************************** */
body {
background: url("");
background-color: rgb(51, 51, 51);
background-repeat: no-repeat;
background-size: cover;
font-family: 'Oswald', sans-serif;
color: white;
letter-spacing: 2px;
}
/* LOOK # NAV AND THEN # UL */
.nav>ul {
list-style: none;
background-color: rgba(0, 0, 0, 0.6);
text-align: center;
padding: 10px;
width: 100%;
}
.nav>li {
width: 230px;
border-bottom: none;
height: 50px;
line-height: 40px;
display: inline-block;
margin-right: -4px;
}
/* LOOK # NAV THEN # UL THEN # LI*/
.nav>ul>li {
list-style-type: none;
display: inline-block;
padding: 5px 35px 5px 35px;
position: relative;
text-align: left;
line-height: 40px;
font-size: 25px;
}
.nav>ul>li:hover {
background-color: #009933;
}
ul.submenu {
position: absolute;
background-color: #141414;
list-style-type: none;
width: 190px;
padding-left: 0px;
padding-top: 5px;
padding-right: 60px;
margin-top: 5px;
margin-left: -35px;
opacity: 0;
display: none;
}
ul.submenu li {
padding-left: 25px;
padding-top: 5px;
padding-bottom: 5px;
}
/* WHEN HOVER OVER NAV LIST, I WANT SUBMENU TO CHANGE */
.nav li:hover .submenu {
opacity: 1;
display: block;
z-index: 9999;
}
ul.submenu li:hover {
color: white;
}
.nav a {
text-decoration: none;
color: white;
display: block;
padding-left: 15px;
padding-right: 15px;
transition: .3s background-color;
}
.nav a:hover {
background-color: #009933;
color: black;
}
/* ************************************* CONTACT PAGE **************************************** */
#contactInfo ul {
list-style: none;
background: rgba(0, 0, 0, 0.8);
border: 5px black solid;
margin-top: 175px;
margin-left: 750px;
width: 300px;
}
.contactAddress {
font-size: 25px;
text-align: center;
padding: 10px;
display: inline-block;
line-height: 40px;
}
#contactInfo ul li a:link {
text-decoration: none;
background-color: rgba(0, 153, 51, 0.8);
padding: 1px 5px 1px 5px;
color: black;
font-weight: bold;
}
#contactInfo ul li a:visited {
text-decoration: none;
}
#contactInfo ul li a:hover {
text-decoration: underline;
}
#contactInfo ul li a:active {
text-decoration: underline;
}
/* ************************************* ABOUT PAGE **************************************** */
#aboutMe {
font-size: 25px;
text-align: center;
padding: 20px;
display: inline-block;
border: 5px black solid;
background-color: rgba(0, 0, 0, 0.8);
width: 800px;
margin-top: 50px;
margin-left: 550px;
line-height: 35px;
}
/* ************************************* PHOTOGRAPHY PAGE **************************************** */
.picContainer {
width: 1032px;
float: left;
margin-top: 50px;
margin-left: 23%;
background-color: rgba(0, 0, 0, 0.8);
border: 5px black solid;
}
.picContainer h2 {
text-align: center;
font-size: 30px;
}
.pic {
width: 300px;
height: 300px;
margin: 15px;
border: 5px black solid;
}
hr {
height: 10px;
border: 0;
box-shadow: 0 10px 10px -3px black inset;
}
/* ************************************* TOP TO PAGE **************************************** */
#myBtn {
display: none;
/* Hidden by default */
position: fixed;
/* Fixed/sticky position */
bottom: 50px;
/* Place the button at the bottom of the page */
right: 50px;
/* Place the button 30px from the right */
z-index: 99;
/* Make sure it does not overlap */
border: none;
/* Remove borders */
outline: none;
/* Remove outline */
background-color: white;
/* Set a background color */
color: black;
/* Text color */
cursor: pointer;
/* Add a mouse pointer on hover */
padding: 10px;
/* Some padding */
border-radius: 3px;
/* Rounded corners */
font-family: 'Oswald', sans-serif;
letter-spacing: 2px;
font-weight: bolder;
font-size: 15px;
}
#myBtn:hover {
background-color: #009933;
/* Add a dark-grey background on hover */
}
<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="sawdust.css" />
<title>Sawdust &amp Splinters</title>
<link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet">
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<header>
<div class="nav">
<ul class="mainmenu">
<li>Home</li>
<li>Photography
<ul class="submenu">
<li>Belize</li>
<li>Fernie BC</li>
<li>Montana</li>
<li>Philippines</li>
<li>Lake Tahoe</li>
<li>The Kids</li>
</ul>
</li>
<li>Woodworking
<ul class="submenu">
<li>Furniture</li>
<li>Cutting Boards</li>
<li>Bandsaw Boxes</li>
<li>Keepsake Boxes</li>
<li>Odds &amp Ends</li>
</ul>
<li>About</li>
<li>Contact</li>
</ul>
</div>
</header>
<button onclick="topFunction()" id="myBtn" title="Go to top">Go back to top</button>
<div class=picContainer>
<span id="belize">
<h2>BELIZE</h2>
<img class="pic" src="photos/belize/pano-thumb.jpg" alt="San Pedro Panoramic"/>
<img class="pic" src="photos/belize/broken-thumb.jpg" alt="San Pedro Broken Bridge"/>
<img class="pic" src="photos/belize/beach-thumb.jpg" alt="San Pedro Beach"/>
<img class="pic" src="photos/belize/ruins-thumb.jpg" alt="Xunantunich Ruins"/>
<img class="pic" src="photos/belize/zoo1-thumb.jpg" alt="San Pedro Zoo"/>
<img class="pic" src="photos/belize/zoo2-thumb.jpg" alt="San Pedro Zoo"/>
<img class="pic" src="photos/belize/zoo3-thumb.jpg" alt="San Pedro Zoo"/>
<img class="pic" src="photos/belize/zoo4-thumb.jpg" alt="San Pedro Zoo"/>
<img class="pic" src="photos/belize/cotton-tree-thumb.jpg" alt="Belize Cotton Tree"/>
</span>
<br>
<br>
<br>
<br>
<hr>
<span id="fernie">
<h2>FERNIE, BC</h2>
<img class="pic" src="photos/fernie/fernie-thumb.jpg" alt="Fernie"/>
</span>
<br>
<br>
<br>
<br>
<hr>
<span id="montana">
<h2>MONTANA</h2>
<img class="pic" src="photos/montana/dog-park-mtns-thumb.jpg" alt="Spanish Peaks"/>
<img class="pic" src="photos/montana/fairy-lake-bw-thumb.jpg" alt="Fairy Lake"/>
<img class="pic" src="photos/montana/gallatin-thumb.jpg" alt="Gallatin River"/>
<img class="pic" src="photos/montana/grotto-thumb.jpg" alt="Grott Falls"/>
<img class="pic" src="photos/montana/hyalite-thumb.jpg" alt="Hyalite River"/>
<img class="pic" src="photos/montana/mtns-thumb.jpg" alt="Mountains"/>
<img class="pic" src="photos/montana/natural-thumb.jpg" alt="Natural Bridge Falls"/>
<img class="pic" src="photos/montana/palisades1-thumb.jpg" alt="Palisades Mountain"/>
<img class="pic" src="photos/montana/palisades2-thumb.jpg" alt="Palisades Falls"/>
<img class="pic" src="photos/montana/sunset1-thumb.jpg" alt="Sunset"/>
<img class="pic" src="photos/montana/sunset2-thumb.jpg" alt="Sunset"/>
<img class="pic" src="photos/montana/sunset3-thumb.jpg" alt="Sunset"/>
</span>
<br>
<br>
<br>
<br>
<hr>
<span id="philippines">
<h2>PHILIPPINES</h2>
<img class="pic" src="photos/philippines/temple-thumb.jpg" alt="Sunken Temple"/>
<img class="pic" src="photos/philippines/katibawasan-thumb.jpg" alt="Katibawasan Falls"/>
<img class="pic" src="photos/philippines/camiguin1-thumb.jpg" alt="Camiguin"/>
<img class="pic" src="photos/philippines/camiguin2-thumb.jpg" alt="Camiguin"/>
<img class="pic" src="photos/philippines/camiguin3-thumb.jpg" alt="Camiguin"/>
<img class="pic" src="photos/philippines/camiguin4-thumb.jpg" alt="Camiguin"/>
<img class="pic" src="photos/philippines/camiguin5-thumb.jpg" alt="Camiguin"/>
</span>
<br>
<br>
<br>
<br>
<hr>
<span id="tahoe">
<h2>LAKE TAHOE</h2>
<img class="pic" src="photos/tahoe/tahoe1-thumb.jpg" alt="Lake Tahoe"/>
<img class="pic" src="photos/tahoe/tahoe2-thumb.jpg" alt="Lake Tahoe"/>
<img class="pic" src="photos/tahoe/tahoe3-thumb.jpg" alt="Lake Tahoe"/>
<img class="pic" src="photos/tahoe/tahoe4-thumb.jpg" alt="Lake Tahoe"/>
<img class="pic" src="photos/tahoe/tahoe5-thumb.jpg" alt="Lake Tahoe"/>
</span>
</div>
</body>
</html>
Just add visibility:hidden; and visibility:visible;
ul.submenu {
position: absolute;
background-color: #141414;
list-style-type: none;
width: 190px;
padding-left: 0px;
padding-top: 5px;
padding-right: 60px;
margin-top: 15px;
margin-left: -35px;
opacity: 0;
visibility:hidden; //add this
}
.nav li:hover .submenu {
opacity: 1;
visibility:visible; //add this
}
$("#cssmenu").menumaker({
title: "Menu",
breakpoint: 768,
format: "multitoggle"
});
#import url(https://fonts.googleapis.com/css?family=Montserrat:400,700);
#cssmenu,
#cssmenu ul,
#cssmenu ul li,
#cssmenu ul li a,
#cssmenu #menu-button {
margin: 0;
padding: 0;
border: 0;
list-style: none;
line-height: 1;
display: block;
position: relative;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#cssmenu:after,
#cssmenu > ul:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
#cssmenu #menu-button {
display: none;
}
#cssmenu {
font-family: Montserrat, sans-serif;
background: #333333;
}
#cssmenu > ul > li {
float: left;
}
#cssmenu.align-center > ul {
font-size: 0;
text-align: center;
}
#cssmenu.align-center > ul > li {
display: inline-block;
float: none;
}
#cssmenu.align-center ul ul {
text-align: left;
}
#cssmenu.align-right > ul > li {
float: right;
}
#cssmenu > ul > li > a {
padding: 17px;
font-size: 12px;
letter-spacing: 1px;
text-decoration: none;
color: #dddddd;
font-weight: 700;
text-transform: uppercase;
}
#cssmenu > ul > li:hover > a {
color: #00ff00;
}
#cssmenu > ul > li.has-sub > a {
padding-right: 30px;
}
#cssmenu > ul > li.has-sub > a:after {
position: absolute;
top: 22px;
right: 11px;
width: 8px;
height: 2px;
display: block;
background: #dddddd;
content: '';
}
#cssmenu > ul > li.has-sub > a:before {
position: absolute;
top: 19px;
right: 14px;
display: block;
width: 2px;
height: 8px;
background: #dddddd;
content: '';
-webkit-transition: all .25s ease;
-moz-transition: all .25s ease;
-ms-transition: all .25s ease;
-o-transition: all .25s ease;
transition: all .25s ease;
}
#cssmenu > ul > li.has-sub:hover > a:before {
top: 23px;
height: 0;
}
#cssmenu ul ul {
position: absolute;
left: -9999px;
}
#cssmenu.align-right ul ul {
text-align: right;
}
#cssmenu ul ul li {
height: 0;
-webkit-transition: all .25s ease;
-moz-transition: all .25s ease;
-ms-transition: all .25s ease;
-o-transition: all .25s ease;
transition: all .25s ease;
}
#cssmenu li:hover > ul {
left: auto;
}
#cssmenu.align-right li:hover > ul {
left: auto;
right: 0;
}
#cssmenu li:hover > ul > li {
height: 35px;
}
#cssmenu ul ul ul {
margin-left: 100%;
top: 0;
}
#cssmenu.align-right ul ul ul {
margin-left: 0;
margin-right: 100%;
}
#cssmenu ul ul li a {
border-bottom: 1px solid rgba(150, 150, 150, 0.15);
padding: 11px 15px;
width: 170px;
font-size: 12px;
text-decoration: none;
color: #dddddd;
font-weight: 400;
background: #333333;
}
#cssmenu ul ul li:last-child > a,
#cssmenu ul ul li.last-item > a {
border-bottom: 0;
}
#cssmenu ul ul li:hover > a,
#cssmenu ul ul li a:hover {
color: #00ff00;
}
#cssmenu ul ul li.has-sub > a:after {
position: absolute;
top: 16px;
right: 11px;
width: 8px;
height: 2px;
display: block;
background: #dddddd;
content: '';
}
#cssmenu.align-right ul ul li.has-sub > a:after {
right: auto;
left: 11px;
}
#cssmenu ul ul li.has-sub > a:before {
position: absolute;
top: 13px;
right: 14px;
display: block;
width: 2px;
height: 8px;
background: #dddddd;
content: '';
-webkit-transition: all .25s ease;
-moz-transition: all .25s ease;
-ms-transition: all .25s ease;
-o-transition: all .25s ease;
transition: all .25s ease;
}
#cssmenu.align-right ul ul li.has-sub > a:before {
right: auto;
left: 14px;
}
#cssmenu ul ul > li.has-sub:hover > a:before {
top: 17px;
height: 0;
}
#cssmenu.small-screen {
width: 100%;
}
#cssmenu.small-screen ul {
width: 100%;
display: none;
}
#cssmenu.small-screen.align-center > ul {
text-align: left;
}
#cssmenu.small-screen ul li {
width: 100%;
border-top: 1px solid rgba(120, 120, 120, 0.2);
}
#cssmenu.small-screen ul ul li,
#cssmenu.small-screen li:hover > ul > li {
height: auto;
}
#cssmenu.small-screen ul li a,
#cssmenu.small-screen ul ul li a {
width: 100%;
border-bottom: 0;
}
#cssmenu.small-screen > ul > li {
float: none;
}
#cssmenu.small-screen ul ul li a {
padding-left: 25px;
}
#cssmenu.small-screen ul ul ul li a {
padding-left: 35px;
}
#cssmenu.small-screen ul ul li a {
color: #dddddd;
background: none;
}
#cssmenu.small-screen ul ul li:hover > a,
#cssmenu.small-screen ul ul li.active > a {
color: #00ff00;
}
#cssmenu.small-screen ul ul,
#cssmenu.small-screen ul ul ul,
#cssmenu.small-screen.align-right ul ul {
position: relative;
left: 0;
width: 100%;
margin: 0;
text-align: left;
}
#cssmenu.small-screen > ul > li.has-sub > a:after,
#cssmenu.small-screen > ul > li.has-sub > a:before,
#cssmenu.small-screen ul ul > li.has-sub > a:after,
#cssmenu.small-screen ul ul > li.has-sub > a:before {
display: none;
}
#cssmenu.small-screen #menu-button {
display: block;
padding: 17px;
color: #dddddd;
cursor: pointer;
font-size: 12px;
text-transform: uppercase;
font-weight: 700;
}
#cssmenu.small-screen #menu-button:after {
position: absolute;
top: 22px;
right: 17px;
display: block;
height: 4px;
width: 20px;
border-top: 2px solid #dddddd;
border-bottom: 2px solid #dddddd;
content: '';
box-sizing: content-box;
}
#cssmenu.small-screen #menu-button:before {
position: absolute;
top: 16px;
right: 17px;
display: block;
height: 2px;
width: 20px;
background: #dddddd;
content: '';
box-sizing: content-box;
}
#cssmenu.small-screen #menu-button.menu-opened:after {
top: 23px;
border: 0;
height: 2px;
width: 15px;
background: #00ff00;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
#cssmenu.small-screen #menu-button.menu-opened:before {
top: 23px;
background: #00ff00;
width: 15px;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
}
#cssmenu.small-screen .submenu-button {
position: absolute;
z-index: 99;
right: 0;
top: 0;
display: block;
border-left: 1px solid rgba(120, 120, 120, 0.2);
height: 46px;
width: 46px;
cursor: pointer;
}
#cssmenu.small-screen .submenu-button.submenu-opened {
background: #262626;
}
#cssmenu.small-screen ul ul .submenu-button {
height: 34px;
width: 34px;
}
#cssmenu.small-screen .submenu-button:after {
position: absolute;
top: 22px;
right: 19px;
width: 8px;
height: 2px;
display: block;
background: #dddddd;
content: '';
}
#cssmenu.small-screen ul ul .submenu-button:after {
top: 15px;
right: 13px;
}
#cssmenu.small-screen .submenu-button.submenu-opened:after {
background: #00ff00;
}
#cssmenu.small-screen .submenu-button:before {
position: absolute;
top: 19px;
right: 22px;
display: block;
width: 2px;
height: 8px;
background: #dddddd;
content: '';
}
#cssmenu.small-screen ul ul .submenu-button:before {
top: 12px;
right: 16px;
}
#cssmenu.small-screen .submenu-button.submenu-opened:before {
display: none;
}
#cssmenu.small-screen.select-list {
padding: 5px;
}
<!DOCTYPE html>
<html>
<head><meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- jQuery -->
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<!-- MenuMaker Plugin -->
<script src="https://s3.amazonaws.com/menumaker/menumaker.min.js"></script>
<!-- Icon Library -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="cssmenu">
<ul>
<li><i class="fa fa-fw fa-home"></i> Home</li>
<li><i class="fa fa-fw fa-camera"></i> Photography
<ul>
<li>Belize</li>
<li>Fernie BC</li>
<li>Montana</li>
<li>Philippines</li>
<li>Lake Tahoe</li>
<li>The Kids</li>
</ul>
</li>
<li><i class="fa fa-fw fa-magic"></i> Woodworking
<ul>
<li>Furniture</li>
<li>Cutting Boards</li>
<li>Bandsaw Boxes</li>
<li>Keepsake Boxes</li>
<li>Odds & Ends</li>
</ul>
</li>
<li><i class="fa fa-fw fa-info"></i> About</li>
<li><i class="fa fa-fw fa-phone"></i> Contact</li>
</ul>
</div>
</body>
</html>

Why isn't my nav class expanding to 100% of the width?

So I'm trying to understand why when I specify the width for my .thenav class it is not expanding to the entire width of the page.
I UNDERSTAND that it is taking the characteristics of the .container class, but I don't understand why and what is the solution seeing that i specified the width? PLEASE HELP!
Here is my picture of what's happening (I attached an image of what's happening because the jsfiddle makes the div appear at 100% and it's not):
http://imgur.com/a/zsBqC
Here is my jsfiddle:
https://jsfiddle.net/CheckLife/yox7Ln1b/3/
Here's the code for reference:
HTML:
<div class="header">
<div class="container">
<h1 id="box" onload="changed()"><image src="nbaone.png" width="40px" height="55px" class="nba">NBA Legends</h1>
<div class="thenav" onload="changed()">
<ul>
<li><a href="http://www.nba.com"/>Home</a></li>
<li onclick="changeP()">About</li>
<li>Players
<ul>
<li onmouseover="slow()"></li>
<li><a href="#kobesec"/>Kobe</a></li>
<li><a href="#"/>Kevin Durant</a></li>
<li><a href="#"/>The Goat</a></li>
</ul>
</li>
<li onclick="slow()">News</li>
</ul>
</div>
</div>
</div>
CSS:
* {
margin: 0;
padding: 0;
list-style-type: none;
text-decoration: none;
}
header, nav, section, aside, footer, article {
display: block;
}
body {
background-image: url(backwood.png);
width: 100%;
margin: auto;
}
.container {
margin: 0px auto;
background-size: cover;
width: 1300px;
height: 100%;
}
.header {
background:linear-gradient(to right, #5092f4, #f29641);
margin-top: 0px;
width: 100%;
}
.header h1{
text-align: center;
width: 100%;
padding-bottom: 15px;
font-family: Arial, Helvetica, sans-serif;
color: #f4ca1f;
}
.tmacw {
display:inline;
position: relative;
padding: 0px;
top: 5px;
}
.nba {
margin-right: 10px;
}
.thenav {
background-color: #7886a3;
width: 100%;
height: 85px;
position: relative;
z-index: 1;
}
/* Style for the Nav Bar */
.thenav ul {
padding: 0;
margin: 0;
}
.thenav ul li {
float: left;
width: 90px;
text-align: center;
border-right: 1px groove #141e38;
position: relative;
}
.thenav ul li a {
display: block;
color: white;
font-weight: bold;
padding: 33px 10px;
}
.thenav ul li a:hover {
background-color: #47e586;
transition: all 0.90s;
}
/*Dropdown Nav */
.thenav li ul li{
background-color: #7886a3;
border: 2px groove grey;
border-radius: 4px;
position: relative;
}
.thenav li ul li a {
padding: 8px;
text-align:left;
}
.thenav li ul li:nth-child(1) a:hover {
background-color: #F47575;
}
.thenav li ul li:nth-child(2) a:hover {
background-color: #f7d759 ;
}
.thenav li ul li a:hover{
background-color: red;
}
.thenav ul li ul {
display: none;
}
.thenav li:hover ul{
position:absolute;
}
.thenav li:hover ul{
display: block;
}
/* End of Dropdown */
.userlogin {
font-size: 12px;
top:2px;
color: white;
}
input[type=text], input[type=password] {
font-weight: bold;
margin: 0;
font-size: 8px;
height: 10px;
padding: 3px 5px 3px 5px;
color: 162354;
}
/* Stats Button */
.stat input[type=button] {
background-color: #6cd171;
color: blue;
border-radius: 6px;
font-weight: bold;
border: none;
float: left;
margin-top: 20px;
margin-left: 20px;
padding: 2px 2px;
font-family: Verdana, Geneva, sans-serif;
}
.log[type=button] {
background-color: white;
color: #008cff;
border-radius: 4px;
font-weight: bold;
border: none;
padding: 1px 2px 2px 2px;
position: relative;
left: 5px;
top: 3px;
}
A child div that does not have absolute positioning and has a width of 100% (unnecessary if it's display is the default of block) will be set to it's containers width. Your div.container has a width setting of 1300px and it is the parent element of div.thenav, therefore div.thenav's width will also be 1300px.
You can either remove width on the container:
.container {
margin: 0px auto;
background-size: cover;
/*width: 1300px; remove this */
height: 100%;
}
or:
Move div.thenav outside of div.container as in this code:
(https://jsfiddle.net/nod19rze/)
<div class="header">
<h1 id="box" onload="changed()"><image src="nbaone.png" width="40px" height="55px" class="nba">NBA Legends</h1>
<div class="thenav" onload="changed()">
<!-- contents of thenav here -->
</div>
<div class="container">
</div>
</div>
Either the container should be the first wrapper and then comes the header, which could solve the issue. I am not sure if this is what u need. Please check this fiddle:
https://jsfiddle.net/estgLn1q/1/
<div class="container">
<div class="header">
</div>
</div>
Or if you want to maintain the same html structure, then remove width:1300px from '.container' which will cause the container to take the same width as of its parent.
I would just move #box and .thenav out of .container and start that class after those elements.
* {
margin: 0;
padding: 0;
list-style-type: none;
text-decoration: none;
}
header,
nav,
section,
aside,
footer,
article {
display: block;
}
body {
background-image: url(backwood.png);
width: 100%;
margin: auto;
}
.container {
margin: 0px auto;
background-size: cover;
width: 1300px;
height: 100%;
}
.header {
background: linear-gradient(to right, #5092f4, #f29641);
margin-top: 0px;
width: 100%;
}
.header h1 {
text-align: center;
width: 100%;
padding-bottom: 15px;
font-family: Arial, Helvetica, sans-serif;
color: #f4ca1f;
}
.tmacw {
display: inline;
position: relative;
padding: 0px;
top: 5px;
}
.nba {
margin-right: 10px;
}
.thenav {
background-color: #7886a3;
width: 100%;
height: 85px;
position: relative;
z-index: 1;
}
/* Style for the Nav Bar */
.thenav ul {
padding: 0;
margin: 0;
}
.thenav ul li {
float: left;
width: 90px;
text-align: center;
border-right: 1px groove #141e38;
position: relative;
}
.thenav ul li a {
display: block;
color: white;
font-weight: bold;
padding: 33px 10px;
}
.thenav ul li a:hover {
background-color: #47e586;
transition: all 0.90s;
}
/*Dropdown Nav */
.thenav li ul li {
background-color: #7886a3;
border: 2px groove grey;
border-radius: 4px;
position: relative;
}
.thenav li ul li a {
padding: 8px;
text-align: left;
}
.thenav li ul li:nth-child(1) a:hover {
background-color: #F47575;
}
.thenav li ul li:nth-child(2) a:hover {
background-color: #f7d759;
}
.thenav li ul li a:hover {
background-color: red;
}
.thenav ul li ul {
display: none;
}
.thenav li:hover ul {
position: absolute;
}
.thenav li:hover ul {
display: block;
}
/* End of Dropdown */
.userlogin {
font-size: 12px;
top: 2px;
color: white;
}
input[type=text],
input[type=password] {
font-weight: bold;
margin: 0;
font-size: 8px;
height: 10px;
padding: 3px 5px 3px 5px;
color: 162354;
}
/* Stats Button */
.stat input[type=button] {
background-color: #6cd171;
color: blue;
border-radius: 6px;
font-weight: bold;
border: none;
float: left;
margin-top: 20px;
margin-left: 20px;
padding: 2px 2px;
font-family: Verdana, Geneva, sans-serif;
}
.log[type=button] {
background-color: white;
color: #008cff;
border-radius: 4px;
font-weight: bold;
border: none;
padding: 1px 2px 2px 2px;
position: relative;
left: 5px;
top: 3px;
<div class="header">
<h1 id="box" onload="changed()"><image src="nbaone.png" width="40px" height="55px" class="nba">NBA Legends</h1>
<div class="thenav" onload="changed()">
<ul>
<li><a href="http://www.nba.com" />Home</a>
</li>
<li onclick="changeP()">About</li>
<li>Players
<ul>
<li onmouseover="slow()">
</li>
<li><a href="#kobesec" />Kobe</a>
</li>
<li><a href="#" />Kevin Durant</a>
</li>
<li><a href="#" />The Goat</a>
</li>
</ul>
</li>
<li onclick="slow()">News</li>
</ul>
</div>
<div class="container">
</div>
</div>