How to restrict the row size of a CSS Grid? - html

I have a CSS Grid layout where the top row size increases on decreasing the view port size, which is not what I want.
I don't know what changes I have to make so that the top row size doesn't increase.
/* change border colour to suit your needs */
html{
background-color:azure;
}
.sideNav{
background: #eee;
text-decoration: none;
font-size: 1.25vw;
color:blueviolet;
margin:10px 5px 10px 0px;
margin-top: 200px;
position:absolute;
}
table{
background-color: #eee;
width:100%;
border-spacing:2px;
}
th{
background:azure;
padding:5px;
}
td{
border-bottom: 1px solid white;
padding:5px;
font-size=1vw;
}
/*specific selectors*/
th.No {
text-align:center;
}
td.No {
text-align:center;
}
.heading1{
font-family:sans-serif;
font-size:2vw;
text-align:center;
background-color:blue;
color:white;
border-radius:2px;
}
.heading2{
font-family:sans-serif;
font-size:20px;
text-align:left;
margin-top:10px;
color:black;
border-radius:5px;
}
body{
background-color:white;
}
.container{
display:grid;
grid-template-columns:repeat(6, 1fr);
grid-template-rows:repeat(8, 1fr);
grid-template-areas:
"top top top top top top "
"Lbar main main main main Rbar"
"Lbar main main main main Rbar"
"Lbar main main main main Rbar"
"Lbar main main main main Rbar"
"Lbar main main main main Rbar"
"Lbar main main main main Rbar"
"foot foot foot foot foot foot"
}
.title{
grid-area:top;
}
img{
width:100%;
}
.leftBar{
grid-area: Lbar;
}
ul{
text-decoration: none;
}
.rightBar{
grid-area: Rbar;
}
.contentArea{
grid-area: main;
}
.footerArea{
grid-area: foot;
border:5px;
padding:5px;
height:40%;
text-align:center;
background-color:cornflowerblue;
}
<!-- SlideShow Starts--!>
* {box-sizing:border-box}
/* Slideshow container */
.slideshow-container {
max-width: 1000px;
position: relative;
margin: auto;
}
/* Hide the images by default */
.mySlides {
display: none;
}
/* Next & previous buttons */
.prev, .next {
cursor: pointer;
position: absolute;
top: 50%;
width: auto;
margin-top: -22px;
padding: 16px;
color: black;
font-weight: bold;
font-size: 18px;
transition: 0.6s ease;
border-radius: 0 3px 3px 0;
}
/* 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: ghostwhite;
}
/* 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;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
transition: background-color 0.6s ease;
}
.active, .dot:hover {
background-color: #717171;
}
/* 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}
}
<!-- SlideShow Ends--!>
img .title{
position:fixed;
}
/* Left Menu*/
.navigation {
padding: 0;
margin: 0;
border: 0;
line-height: 1;
}
.navigation ul, .navigation ul li, .navigation ul ul {
list-style: none;
margin: 0;
padding: 0;
}
.navigation ul {
z-index: 500;
float: left;
}
.navigation ul li {
float: left;
min-height: 0.05em;
line-height: 1em;
vertical-align: middle;
position: relative;
}
.navigation ul li.hover,
.navigation ul li:hover {
position: relative;
z-index: 510;
cursor: default;
}
.navigation ul ul {
visibility: hidden;
position: absolute;
top: 100%;
left: 0px;
z-index: 520;
width: 100%;
}
.navigation ul ul li { float: none; }
.navigation ul ul ul {
top: 0;
right: 0;
}
.navigation ul li:hover > ul { visibility: visible; }
.navigation ul ul {
top: 0;
left: 99%;
}
.navigation ul li { float: none; }
.navigation ul ul { margin-top: 0.05em; }
.navigation {
width:100%;
background: #1568ef;
font-family: 'roboto', Tahoma, Arial, sans-serif;
zoom:1;
}
.navigation:before {
content: '';
display: block;
}
.navigation:after {
content: '';
display: table;
clear: both;
}
.navigation a {
display: block;
padding: 1em 1.3em;
color: #ffffff;
text-decoration: none;
text-transform: uppercase;
}
.navigation > ul { width:12em; }
.navigation ul ul { width: auto; }
.navigation > ul > li > a {
border-right: 0.3em solid #34A65F;
color: #ffffff;
}
.navigation > ul > li > a:hover { color: #ffffff; }
.navigation > ul > li a:hover, .navigation > ul > li:hover a { background: #34A65F; }
.navigation li { position: relative; }
.navigation ul li.has-sub > a:after {
content: '»';
position: absolute;
right: 1em;
}
.navigation ul ul li.first {
-webkit-border-radius: 0 3px 0 0;
-moz-border-radius: 0 3px 0 0;
border-radius: 0 3px 0 0;
}
.navigation ul ul li.last {
-webkit-border-radius: 0 0 3px 0;
-moz-border-radius: 0 0 3px 0;
border-radius: 0 0 3px 0;
border-bottom: 0;
}
.navigation ul ul {
-webkit-border-radius: 0 3px 3px 0;
-moz-border-radius: 0 3px 3px 0;
border-radius: 0 3px 3px 0;
}
.navigation ul ul { border: 1px solid #34A65F; }
.navigation ul ul a { color: #ffffff; }
.navigation ul ul a:hover { color: #ffffff; }
.navigation ul ul li { border-bottom: 1px solid #0F8A5F; }
.navigation ul ul li:hover > a {
background: #4eb1ff;
color: #ffffff;
}
.navigation.align-right > ul > li > a {
border-left: 0.3em solid #34A65F;
border-right: none;
}
.navigation.align-right { float: right; }
.navigation.align-right li { text-align: right; }
.navigation.align-right ul li.has-sub > a:before {
content: '+';
position: absolute;
top: 50%;
left: 15px;
margin-top: -6px;
}
.navigation.align-right ul li.has-sub > a:after { content: none; }
.navigation.align-right ul ul {
visibility: hidden;
position: absolute;
top: 0;
left: -100%;
z-index: 598;
width: 100%;
}
.navigation.align-right ul ul li.first {
-webkit-border-radius: 3px 0 0 0;
-moz-border-radius: 3px 0 0 0;
border-radius: 3px 0 0 0;
}
.navigation.align-right ul ul li.last {
-webkit-border-radius: 0 0 0 3px;
-moz-border-radius: 0 0 0 3px;
border-radius: 0 0 0 3px;
}
.navigation.align-right ul ul {
-webkit-border-radius: 3px 0 0 3px;
-moz-border-radius: 3px 0 0 3px;
border-radius: 3px 0 0 3px;
}
<!-- counter-->
.main_container {
height: 146px;
width: auto;
padding: 3px;
margin: 2px;
max-width: 300px;
background-color: #555555;
align-content: center;
}
.container_inner {
height: auto;
border: none;
background-color: #555555;
max-width: 290px;
vertical-align: center;
padding-top: 12px;
padding-left: 10px;
align-content: center;
}
.num_tiles {
width:30px;
height: 30px;
background-color: #888888;
color: #ffffff;
font-size: 22px;
text-align: center;
line-height: 20px;
padding: 3px;
margin: 1.5px;
font-family: verdana;
vertical-align: center;
}
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content= "width=device-width, initial-scale=1.0">"
<link rel="stylesheet" href="meu_css/meustyles.css">
</head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'GA_TRACKING_ID');
</script>
<body>
<div class= "container">
<div class="title"><img src="img_meu/Header%20PGIMS3.png"></div>
<div class="navigation">
<ul>
<li> Officials
<!--<ul>
<li class="has-sub"> Submenu 1.1
<ul>
<li>Submenu 1.1.1</li>
<li class="has-sub">Submenu 1.1.2
<ul>
<li>Submenu 1.1.2.1</li>
<li>Submenu 1.1.2.2</li>
</ul>
</li>
</ul>
</li>
<li>Submenu 1.2</li>
</ul> -->
</li>
<li class="has-sub"> Workshops
<ul>
<li>Faculty programmes</li>
<li>Postgraduate programmes</li>
<li>CME's/sensitization Programmes</li>
</ul>
</li>
<li> Contact Us
<!--<ul>
<li>Submenu 3.1</li>
<li>Submenu 3.2</li>
</ul> -->
</li>
</ul>
</div>
<div class="contentArea">
<div>
<div class="heading1">Medical Education Unit</div>
<!-- Slideshow container -->
<div class="slideshow-container">
<!-- Full-width images with number and caption text -->
<div class="mySlides fade">
<div class="numbertext">1 / 3</div>
<img src="img_meu/imgMeu1.jpg" style="width:100%">
</div>
<div class="mySlides fade">
<div class="numbertext">2 / 3</div>
<img src="img_meu/imgMeu2.jpg" style="width:100%">
</div>
<div class="mySlides fade">
<div class="numbertext">3 / 3</div>
<img src="img_meu/imgMeu3.jpg" style="width:100%">
</div>
<!-- Next and previous buttons -->
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</a>
</div>
<br>
<div><marquee style=" color:blue;font-family:sans-serif;font-size:1.25vw;background-color: #f9f6e3">This page is for information only and is under construction</marquee></div>
</div>
<script>
var slideIndex = 0;
showSlides();
function showSlides() {
var i;
var slides = document.getElementsByClassName("mySlides");
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slideIndex++;
if (slideIndex > slides.length) {slideIndex = 1}
slides[slideIndex-1].style.display = "block";
setTimeout(showSlides, 5000); // Change image every 2 seconds
}
</script>
<div style="overflow-x:auto;">
<div >
<table id = "officials" >
<caption style="font-size:2vw;">Officials</caption>
<tr>
<th class="No">S.No</th>
<th>Name</th>
<th>Designation</th>
</tr>
</tr>
</table>
</div>
</div>
<div>
<table>
<caption style="font:2vw;">Workshops</caption>
<tr>
<th id="facDev">Faculty Development Programmes</th>
</tr>
<tr><td>Thesis writing & Research methodology by team of UCMS, New Delhi organized from 11th -13th August 2015 at Pt. B D Sharma Post Graduate Institute of Medical Sciences, UHS, Rohtak</td></tr>
<tr><td>1st Revised Basic Course Workshop in Medical Education Technologies organized under the aegis of MCI Regional Centre for Medical Education Technologies, Maulana Azad Medical College, New Delhi at Pt. B D Sharma Post Graduate Institute of Medical Sciences, UHS, Rohtak from 17-19 April 2017.</td></tr>
<tr><td>2nd Revised Basic Course Workshop in Medical Education Technologies organized under the aegis of MCI Regional Centre for Medical Education Technologies, Maulana Azad Medical College, New Delhi at Pt. B D Sharma Post Graduate Institute of Medical Sciences, UHS, Rohtak from 27-29 November 2017.</td></tr>
<tr><td>3rd Revised Basic Course Workshop in Medical Education Technologies organized under the aegis of MCI Regional Centre for Medical Education Technologies, Maulana Azad Medical College, New Delhi at Pt. B D Sharma Post Graduate Institute of Medical Sciences, UHS, Rohtak from 26-28 March 2018.</td></tr>
</table>
</div>
<div>
<table>
<tr>
<th id="pgOri">Postgraduate orientation programmes</th>
</tr>
<tr><td>“Thesis protocol writing” workshop for 1st yr MD/MS/MDS (Admn. Year 2017) was held from 4th – 9th September 2017. </td></tr>
<tr><td>“Thesis Protocol Writing” for the 1st year M.D./M.S. residents (Admission year 2018) was held 6th – 11th August, 2018.</td></tr>
</table>
</div>
<div id="contact">
<p class= heading1>Contact</p>
<h3>Dr.Sarita Maggu, Dean, PGIMS</h3>
<p>tel:7988234270</p>
<h3>Dr.Sujata Sethi, Sr.Prof Psychiatry, PGIMS</h3>
<p>tel:9466749009</p>
</div>
</div>
<div class="rightBar"></div>
<div class="footerArea">
<p><strong>Page Designed and Developed by Dept of Information Technology,Pt.B.Sharma University of Health Sciences, Rohtak. &copy sukhdevchandla#gmail.com</strong></p>
</div>
</div>
</body>
</html>

The problem is that your rows, always has a size of 1fr (one fraction) and it will be changed across you resize your viewport.
You can try not define grid-template-rows, and let that the size of the rows be automatic.
In resume, remove or comment this code:
grid-template-rows:repeat(8, 1fr);

Related

Dropdown of Navbar goes behind image slider

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}
}

div class doesn't seem to work

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

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>

Logo and social media icons stuck behind header [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have completed three pages to my website with clean code(checked) however, the most important page, page one is putting through the ringer because I can't seem to get my logo to stay in the left-hand corner(fixed) and appear in front of my header and my social media icons to appear in front of my header and appear in right-hand corner. My first is the only page where the code is kind of wacky. This is my first site. I have tried using z-index as well as float and display: hidden. Now I am just stuck.HELP! PLEASE! I am just about researched out on this one. z-index sends my header to the back logo to the front. I am so close to finishing. I have been stuck on this for 4 weeks.
html,
body{
margin:0px;
padding: 0px;
padding-bottom:25px;
background:url(https://images.unsplash.com/41/NmnKzKIyQsyGIkFjiNsb_20140717_212636-3.jpg?q=80&fm=jpg&s=ce9ba69c9caf7d6483d874466478bc9b) no-repeat
center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
color:#ffffff;
}
#wrapper {
background: #107CBD;
min-height:%;
position:relative;
width:960px;
margin:0 auto;
margin-bottom:-60px; /* Negitive Height of Footer */
}
#header {
width: 100%;
background:#107CBD;
padding:19px;
position:absolute;
left:0;
top:0;
background-color: #107CBD;
}
#header h1{
font-family:Noto sans, sans serif;
font-weight: 200;
color: white;
font-size: 2em;
margin-right: %;
}
#header h2{
font-family:Courgette,cursive;
font-weight: 100;
color: white;
font-size: 2em;
margin-right:%;
}
h1+h2{margin-top:-20px;
}
#body {
padding: 10px;
padding-bottom:60px; /* Height of Footer and some change */
background:#FFF; /* Wrapper BG COLOR */
}
#logo{
text-indent: -999999{
z-index:1;
}
#social-media-icons{float:right;}
#social-media-icons ul li{display:inline;}
#social-media-icon ul li{padding-top: 10px;}
}
#social{
float: right;
}
#socail ul{
margin-top-right: 10px;
#socail li{
dispaly.inline;
}
.social-sidebar-buttons{
width: 15px;
margin-left: 15px;
}
.wrapper{
width:960px;
}
.icon{
float:left;
}
.text{
float:left;
padding-left:25px;
padding-top:40px;
font-family: Noto sans,sans serif;
}
.software ul {
position: relative;
width:80%;
padding:1em 1.5em;
margin: 2em auto;
color:#fff;
background:#107CBD;
overflow: hidden;
font-family:'Noto Sans', sans-serif;
}
.software ul:before{
content: "";
position: absolute;
top:0;
right: 0;
border-width: 0 16px 16px 0;
border-style: solid;
border-color: #fff #fff #107CBD #107CBD;
background: #107CBD;
-web-kit-box-shadow: 0 1px 1px rgba(0,0,0,0.3), -1px 1px 1px rgba(0,0,0.2);
-moz-box-shadow: 0 1px 1px rgba(0,0,0,0.3), -1px 1px 1px rgba(0,0,0.0.2);
/* Firefox 3.0 damage limitation*/
display: block; width: 0;
box-shadow: 0 1px 1px rgba(0,0,0,0.3),1px 1px 1px rgba(0,0,0,0.2);
display: block width 0px;
}
.software ul.rounded{
-moz-border-radius: 5px 0 5px 5px;
border-radius: 5px 0 5px 5px;
}
.software ul.rounded:before{
border-width:8px;
border-color: #fff #fff transparent transparent;
-moz-border-radius: 0 0 0 5px;
border-radius: 0 0 0 5px;
}
.social{
float:right;
margin-right:200px;
margin-top:20px;
}
font-family:'Noto Sans';
}
.content{
width: 1000%;
margin: 0 auto;
}
#import url(http://fonts.googleapis.com/css?family=Raleway);
#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 {
width: auto;
font-family: Raleway, sans-serif;
line-height: 1;
}
#cssmenu > ul {
background: #505050;
}
#cssmenu > ul > li {
float:left;
-webkit-perspective: 1000px;
-moz-perspective: 1000px;
perspective: 1000px;
left: 36%
}
#cssmenu.align-center > ul {
font-size: 0;
text-align: center;
}
#cssmenu.align-center > ul > li {
display: inline-block;
float: none;
}
#cssmenu.align-right > ul > li {
float: right;
}
#cssmenu > ul > li > a {
padding: 16px 20px;
font-size: 14px;
color: #ffffff;
letter-spacing: 1px;
text-transform: uppercase;
text-decoration: none;
background: #505050;
-webkit-transition: all .3s;
-moz-transition: all .3s;
-o-transition: all .3s;
transition: all .3s;
-webkit-transform-origin: 50% 0;
-moz-transform-origin: 50% 0;
transform-origin: 50% 0;
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
transform-style: preserve-3d;
}
#cssmenu > ul > li.active > a {
color: #107CBD;
}
#cssmenu > ul > li:hover > a,
#cssmenu > ul > li > a:hover {
color: #107cbd;
-webkit-transform: rotateX(90deg) translateY(-23px);
-moz-transform: rotateX(90deg) translateY(-23px);
transform: rotateX(90deg) translateY(-23px);
-ms-transform: none;
}
#cssmenu > ul > li > a::before {
position: absolute;
top: 100%;
left: 0;
z-index: -1;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
width: 100%;
height: 100%;
padding: 16px 20px;
color: #107cbd;
background: #1d1d1d;
content: attr(data-title);
-webkit-transition: background 0.3s;
-moz-transition: background 0.3s;
transition: background 0.3s;
-webkit-transform: rotateX(-90deg);
-moz-transform: rotateX(-90deg);
transform: rotateX(-90deg);
-webkit-transform-origin: 50% 0;
-moz-transform-origin: 50% 0;
transform-origin: 50% 0;
-ms-transform: translateY(- -18px);
}
#cssmenu > ul > li:hover > a::before,
#cssmenu > ul > li > a:hover::before {
background: #505050;
}
#cssmenu.small-screen {
width: 100%;
}
#cssmenu.small-screen > ul,
#cssmenu.small-screen.align-center > ul {
width: 100%;
text-align: left;
}
#cssmenu.small-screen > ul > li,
#cssmenu.small-screen.align-center {
float: none;
display: block;
border-top: 1px solid rgba(100, 100, 100, 0.1);
}
#cssmenu.small-screen > ul > li:hover > a,
#cssmenu.small-screen > ul > li > a:hover {
color: #107cbd;
-webkit-transform: none;
-moz-transform: none;
transform: none;
-ms-transform: none;
}
#cssmenu.small-screen > ul > li > a::before {
display: none;
}
#cssmenu.small-screen #menu-button {
display: block;
padding: 16px 20px;
cursor: pointer;
font-size: 14px;
text-decoration: none;
color: #ffffff;
text-transform: uppercase;
letter-spacing: 1px;
background: #505050;
}
#cssmenu.small-screen #menu-button:after {
content: "";
position: absolute;
right: 20px;
top: 17px;
display: block;
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
border-top: 2px solid #ffffff;
border-bottom: 2px solid #ffffff;
width: 22px;
height: 3px;
}
#cssmenu.small-screen #menu-button.menu-opened:after {
border-top: 2px solid #107cbd;
border-bottom: 2px solid #107cbd;
}
#cssmenu.small-screen #menu-button:before {
content: "";
position: absolute;
right: 20px;
top: 27px;
display: block;
width: 22px;
height: 2px;
background: #ffffff;
}
#cssmenu.small-screen #menu-button.menu-opened:before {
background: #107cbd;
}
div nav ul li{
text-align: left;
display: inline;
width: %;
float:left;
margin-right: .8em;
font-family: 'Noto Sans';
}
li.changeBackground {
background-color: #505050;
}
li.changeBackground:hover {
background-color: #777777;
}
li.changeBackground:active {
background-color: #107CBD;
}
.homepage-hero-module {
border-right: none;
border-left: none;
position: relative;
}
p{
position:relative;
width: 30%;
padding:1em 1.5em;
margin:2em auto;
color: #fff;
background:#107CBD;
overflow: hidden;
font-family:'Noto Sans';
}
p:before{
content: "";
position: absolute;
top: 0;
right: 0;
border-width: 0 16px 16px 0;
border-style: solid;
border-color: #fff #fff #505050 #505050;
background: #505050;
-web-kit-box-shadow: 0 1px 1px rgba(0,0,0,0.3), -1px; rgba(0,0,0.2);
-moz-box-shadow: 0 1px 1px rgba(0,0,0,0.3), -1px 1px 1px;rgba(0,0,0.2);
box-shadow:0 1px 1px rgba(0,0,0,0,0.3), -1px 1px 1px rgba(0,0,0 0.2);
/* Firefox 3.0 damage limitation*/
display: block; width: 0;
}
p.rounded{
-moz-border-radius: 5px 0 5px 5px;
border-radius: 5px 0 5px 5px;
}
.p.rounded:before{
border-width: 9px;
border-color: #fff #fff transparent transparent;
-moz-border-radius: 0 0 0 5px;
border-radius: 0 0 0 5px;
}
h3{
font-family:'Noto-Sans', sans-serif;
}
#footer{
position: fixed;
bottom:0px;
}
#footer{
margin: 1px;
height:100px;
width: 100%;
border-top: 3px solid #107CBD;
clear: both;
color: #fff;
line-height:20px;
background-color: #505050;
text-align:center;
position:fixed;
font-size:12px;
bottom:0px;
}
#footer ul li a{
text-decoration: none;
font-family: Noto-sans,sans serif;
padding:2em 1em;
color: #fff;
}
#footer ul li a: hover{
color: #000;
background-color:#777777;
}
!DOCTYPE html>
<html lang= "en">
<head>
<meta charset="utf-8">
<link rel="shortcut icon" href="path to icon/favicon.ico"/>
<link href='https://fonts.googleapis.com/css?family=Noto+Sans' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Courgette' rel='stylesheet' type='text/css'>
<title>Dawn's website</title>
</head><
<div id="wrapper">
<header id="logo">
<ahref="index.html"<img src="images/onebugforwebdt.jpg"
alt= "One Bug Design" width="60" height="64">
</header>
</div>
<div class="social">
<ul>
<li><img src="images/Twitter-2-icon.png"></li>
<li><img src="images/Linkedin-icon.png"></li>
<li><img src="images/pinterest-icon.png"></li>
</ul>
</div>
<body id="home"
<div id="wrapper">
<header id="logo">
<h1 class="logo">one bug logo</h1>
<div id="header">
<h1 align="center">One Bug Design</h1><h2 align="center">Designed To Create</h2>
<h1 class="closer"></h1>
<h2 class="closer"></h2>
</div>
</div>
<div id='cssmenu'>
<ul>
<li class='active'><a href='index.html'>Home</a></li>
<li><a href='#'>Portfolio</a></li>
<li><a href='#'>Finds</a></li>
<li><a href='Contact.html'>Contact</a></li>
</ul>
</div>
<div id="content"
</div>
</nav>
<main class="content">
<div class="wrap">
</div>
</div>
<p>
Dawn here, your friendly graphic designer. Do you need someone to make your brand sparkle with desire? Someone to show your logo some love. Do you need someone who truly enjoys the overall creative process and has an eye for great design? Someone who is fluent in the ways of the Adobe CC Master. Someone who will listen and fulfill your visual communication needs. Someone who is determined and who has Ideation? Well click no further! You have arrived at your destination. ........<strong>Welcome!</strong></p>
<section>
<h3>Software skills</h3>
<div class="wrapper">
<div class="icon"><img alt="Illustrator icon" src=
"images/Adobe-Ai-icon.png" width="50px">
<img alt="Indesign icon" src="images/Adobe-Id-icon.png" width="50px">
<img alt="Photoshop icon" src="images/Adobe-PS-icon.png" width="50px">
<img alt="Bridge icon" src="images/bridge-icon.png" width="50px">
<img alt="Camera icon" src="images/Camera-Nikon-Coolpix-L820-02-icon.png" width="50px">
<img alt="HTML icon" src="images/HTML-5-icon.png" width="50px">
<img alt="CSS icon" src="images/css-icon.png" width="50px">
<img alt="Microsoft Office" src="images/Office-icon.png" width="50px"></div>
<div class="text">
Illustrator |
Indesign |
Photoshop |
Bridge |
DSLR|
HTML5 |
CSS |
Microsoft Office |
</div>
</div>
</section>
<div id="social">
<ul>
<li><img src="images/Twitter-2-icon.png"></li>
<li><img src="images/Linkedin-icon.png"></li>
<li><img src="images/pinterest-icon.png"></li>
</ul>
</div>
<div id="footer">
<div id="nav">
<nav class="sitemenu">
<div class="navwrapper">
<ul>
<li class="changeBackground">Home</li>
<li class="changeBackground">Portfolio</li>
<li class="changeBackground">Finds</li>
<li class="changeBackground">Contact</li>
<li>©2015-2016 One Bug Design All Rights Reserved</li>
</ul>
</div>
</nav>
</ul>
<br>
<p class="footer-text">
<div class="social">
<h3 align="right">Stay connected</h3>
<a class= "social twitter" ahref="https://twitter.com/fraggleart">img src="images/Twitter-2-icon.png"</a>
<a class="social pinterest" ahref="https://pinterest.com/rasberry14">img src="images/Pinterest-icon.png"</a>
<a class="social linkedin"ahref="https://linkedin.com/in/dawncthomas">img src="images/Linkedin-icon.png"</a>
</div> </div>
</footer>
</body>
</html>
Add these properties to social class like this.
.social {
float: right;
position: relative;
z-index: 9999;
}
a very HORRIBLE ERROR that you are committing is declaring .wrapper div
</head><
<div id="wrapper">
outside the body tag right after where the <head> tag ends. which shows a very poorly formatted HTML5 markup. I have written a sematically correct html5 markup for you to act as guide along with some css style that shows logo to the left and social links (in my case its just list items, you should change them with image links properly) to the right and also in front of header (the problem you are facing).
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<!-- <link rel="stylesheet" href="stackof.css">-->
</head>
<body>
<style>
html, body {
margin: 0;
padding: 0;
border: 0;
}
body {
background:url(https://images.unsplash.com/41/NmnKzKIyQsyGIkFjiNsb_20140717_212636-3.jpg?q=80&fm=jpg&s=ce9ba69c9caf7d6483d874466478bc9b) no-repeat
center center fixed;
}
.wrapper {
max-height: 100%;
}
header {
max-width: 100%;
}
header .left-col {
max-width: 35%;
float: left;
margin-left: 5%;
margin-top: 5%;
}
.right-col {
width: 70%;
float: right;
}
.right-col ul {
width: 100%;
}
.right-col ul li {
list-style: none;
float: left;
display: block;
padding-top: 5%;
margin-left: 5%;
}
.right-col li a {
text-decoration: none;
color: aliceblue;
}
</style>
<div id="wrapper">
<header id="logo">
<div class="left-col">
<a href="#">
<img src="pro/images/logo.png" alt="">
</a>
</div>
<div class="right-col social-links">
<ul>
<li>Lorem.</li>
<li>Minus.</li>
<li>Nulla.</li>
<li>Cum.</li>
<li>Ratione!</li>
</ul>
</div>
</header>
<main>
<!--write your sections here-->
<section class="setion-1"></section>
<section class="section-2"></section>
<aside></aside>
</main>
<footer>
<!--your footer goes here-->
</footer>
</div>
</body>
</html>
you should cut/paste the style data into any file you name with .css format i.e. stackof.css in my case to make it look more nice and un-comment the link tag.

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

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