Cant get second hamburger menu to work - html

I was able to get MENU-1 to collapse into a hamburger menu for smaller devices, but cant seem to get MENU-2 to do the same. Can someone tell me where i'm going wrong because i've tried replicating MENU1 codes but to no avail
.cd-auto-hide-header {
position: fixed;
z-index: 2;
top: 0;
left: 0;
width: 100%;
height: 60px;
background-color: #ffffff;
/* Force Hardware Acceleration */
-webkit-transform: translateZ(0);
transform: translateZ(0);
will-change: transform;
-webkit-transition: -webkit-transform .5s;
transition: -webkit-transform .5s;
transition: transform .5s;
transition: transform .5s, -webkit-transform .5s;
}
.cd-auto-hide-header::after {
clear: both;
content: "";
display: block;
}
.cd-auto-hide-header.is-hidden {
-webkit-transform: translateY(-100%);
-ms-transform: translateY(-100%);
transform: translateY(-100%);
}
#media only screen and (min-width: 1024px) {
.cd-auto-hide-header {
height: 80px;
}
}
.cd-auto-hide-header .logo,
.cd-auto-hide-header .nav-trigger {
position: absolute;
top: 50%;
bottom: auto;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
.cd-auto-hide-header .logo {
left: 5%;
}
.cd-auto-hide-header .logo a, .cd-auto-hide-header .logo img {
display: block;
}
.cd-auto-hide-header .nav-trigger
{
/* vertically align its content */
display: table;
height: 100%;
padding: 0 1em;
font-size: 1.2rem;
text-transform: uppercase;
color: #25283D;
font-weight: bold;
right: 0;
border-left: 1px solid #f2f2f2;
}
.cd-auto-hide-header .nav-trigger span
{
/* vertically align inside parent element */
display: table-cell;
vertical-align: middle;
}
.cd-auto-hide-header .nav-trigger em, .cd-auto-hide-header .nav-trigger em::after, .cd-auto-hide-header .nav-trigger em::before {
/* this is the menu icon */
display: block;
position: relative;
height: 2px;
width: 22px;
background-color: #25283D;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.cd-auto-hide-header .nav-trigger em
{
/* this is the menu central line */
margin: 6px auto 14px;
-webkit-transition: background-color .2s;
transition: background-color .2s;
}
.cd-auto-hide-header .nav-trigger em::before, .cd-auto-hide-header .nav-trigger em::after {
position: absolute;
content: '';
left: 0;
-webkit-transition: -webkit-transform .2s;
transition: -webkit-transform .2s;
transition: transform .2s;
transition: transform .2s, -webkit-transform .2s;
}
.cd-auto-hide-header .nav-trigger em::before
{
/* this is the menu icon top line */
-webkit-transform: translateY(-6px);
-ms-transform: translateY(-6px);
transform: translateY(-6px);
}
.cd-auto-hide-header .nav-trigger em::after
{
/* this is the menu icon bottom line */
-webkit-transform: translateY(6px);
-ms-transform: translateY(6px);
transform: translateY(6px);
}
#media only screen and (min-width: 1024px) {
.cd-auto-hide-header .nav-trigger
{
display: none;
}
}
.cd-auto-hide-header.nav-open .nav-trigger em
{
/* transform menu icon into a 'X' icon */
background-color: rgba(255, 255, 255, 0);
}
.cd-auto-hide-header.nav-open .nav-trigger em::before
{
/* rotate top line */
-webkit-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
transform: rotate(-45deg);
}
.cd-auto-hide-header.nav-open .nav-trigger em::after
{
/* rotate bottom line */
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
.cd-primary-nav {
display: inline-block;
float: right;
height: 100%;
padding-right: 5%;
}
.cd-primary-nav > ul {
position: absolute;
z-index: 2;
top: 60px;
left: 0;
width: 100%;
background-color: #ffffff;
display: none;
box-shadow: 0 14px 20px rgba(0, 0, 0, 0.2);
}
.cd-primary-nav > ul a {
/* target primary-nav links */
display: block;
height: 50px;
line-height: 50px;
padding-left: 5%;
color: #25283D;
font-size: 1.8rem;
border-top: 1px solid #f2f2f2;
}
.cd-primary-nav > ul a:hover, .cd-primary-nav > ul a.active {
color: #8F3985;
}
#media only screen and (min-width: 1024px) {
.cd-primary-nav {
/* vertically align its content */
display: table;
}
.cd-primary-nav > ul {
/* vertically align inside parent element */
display: table-cell;
vertical-align: middle;
/* reset mobile style */
position: relative;
width: auto;
top: 0;
padding: 0;
background-color: transparent;
box-shadow: none;
}
.cd-primary-nav > ul::after {
clear: both;
content: "";
display: block;
}
.cd-primary-nav > ul li {
display: inline-block;
float: left;
margin-right: 1.5em;
}
.cd-primary-nav > ul li:last-of-type {
margin-right: 0;
}
.cd-primary-nav > ul a {
/* reset mobile style */
height: auto;
line-height: normal;
padding: 0;
border: none;
}
}
.nav-open .cd-primary-nav ul,
.cd-primary-nav ul:target {
/*
show primary nav - mobile only
:target is used to show navigation on no-js devices
*/
display: block;
}
#media only screen and (min-width: 1024px) {
.nav-open .cd-primary-nav ul,
.cd-primary-nav ul:target {
display: table-cell;
}
}
/* --------------------------------
2. Auto-Hiding Navigation - with Sub Nav
-------------------------------- */
.cd-secondary-nav {
position: relative;
z-index: 1;
clear: both;
width: 100%;
height: 50px;
background-color: #25283D;
/* Force Hardware Acceleration */
-webkit-transform: translateZ(0);
transform: translateZ(0);
will-change: transform;
-webkit-transition: -webkit-transform .5s;
transition: -webkit-transform .5s;
transition: transform .5s;
transition: transform .5s, -webkit-transform .5s;
}
.cd-secondary-nav::after {
/* gradient on the right - to indicate it's possible to scroll */
content: '';
position: absolute;
z-index: 1;
top: 0;
right: 0;
height: 100%;
width: 35px;
background: transparent;
background: -webkit-linear-gradient(right, #25283D, rgba(37, 40, 61, 0));
background: linear-gradient(to left, #25283D, rgba(37, 40, 61, 0));
pointer-events: none;
-webkit-transition: opacity .2s;
transition: opacity .2s;
}
.cd-secondary-nav.nav-end::after {
opacity: 0;
}
.cd-secondary-nav ul, .cd-secondary-nav li, .cd-secondary-nav a {
height: 100%;
}
.cd-secondary-nav ul {
}
.cd-secondary-nav ul::after {
clear: both;
content: "";
display: block;
}
.cd-secondary-nav li {
display: inline-block;
float: left;
/* do not shrink - elements float on the right of the element */
-webkit-flex-shrink: 0;
-ms-flex-negative: 0;
flex-shrink: 0;
}
.cd-secondary-nav li:last-of-type {
padding-right: 20px;
}
.cd-secondary-nav a {
display: block;
opacity: .6;
line-height: 50px;
padding: 0 1em;
}
.cd-secondary-nav a:hover, .cd-secondary-nav a.active {
opacity: 1;
}
#media only screen and (min-width: 1024px) {
.cd-secondary-nav {
height: 70px;
overflow: visible;
}
.cd-secondary-nav ul {
/* reset mobile style */
display: block;
text-align: center;
}
.cd-secondary-nav li {
/* reset mobile style */
float: none;
-webkit-flex-shrink: 1;
-ms-flex-negative: 1;
flex-shrink: 1;
}
.cd-secondary-nav a {
line-height: 70px;
}
.cd-secondary-nav a.active {
box-shadow: inset 0 -3px #8F3985;
}
}
.cd-secondary-nav.fixed {
position: fixed;
top: 60px;
}
.cd-secondary-nav.slide-up {
-webkit-transform: translateY(-60px);
-ms-transform: translateY(-60px);
transform: translateY(-60px);
}
#media only screen and (min-width: 1024px) {
.cd-secondary-nav.fixed {
top: 80px;
box-shadow: 0 -6px 0 #25283D;
}
.cd-secondary-nav.slide-up {
-webkit-transform: translateY(-80px);
-ms-transform: translateY(-80px);
transform: translateY(-80px);
}
}
<header class="cd-auto-hide-header">
<div class="logo"><img src="img/cd-logo.svg" alt="Logo"></div>
<nav class="cd-primary-nav">
<a href="#cd-navigation" class="nav-trigger">
<span>
<em aria-hidden="true"></em>
MENU-1
</span>
</a> <!-- .nav-trigger -->
<ul id="cd-navigation">
<li>The team</li>
<li>Our Products</li>
<li>Our Services</li>
<li>Shopping tools</li>
<li>Contact Us</li>
</ul>
</nav> <!-- .cd-primary-nav -->
</header> <!-- .cd-auto-hide-header -->
<section class="cd-hero">
<div class="cd-hero-content">
<!-- your content here -->
</div>
</section> <!-- .cd-hero -->
<nav class="cd-secondary-nav">
<span>
<em aria-hidden="true"></em>
MENU-2
</span>
<ul>
<li><a class="active" href="#0">Intro</a></li>
<li>Features</li>
<li>Photos</li>
<li>Videos</li>
<li>Specs</li>
<li>Support</li>
<li>Compare</li>
<li>Buy</li>
</ul>
</nav> <!-- .cd-secondary-nav -->

Related

Side NavBar: imposible to change height and width

I'm using this Pure CSS hamburger menu code: https://codepen.io/Joanc/pen/XYYZdE
body
{
margin: 0;
padding: 0;
/*make it look decent enough*/
background: #232323;
color: #cdcdcd;
font-family: "Avenir Next", "Avenir", sans-serif;
overflow-x: hidden; /*needed because hiding the menu on the right side is not perfect*/
}
a
{
text-decoration: none;
color: #232323;
transition: color 0.3s ease;
}
a:hover
{
color: tomato;
}
#menuToggle
{
display: block;
position: absolute;
top: 50px;
right: 50px;
z-index: 1;
-webkit-user-select: none;
user-select: none;
}
#menuToggle input
{
display: block;
width: 40px;
height: 32px;
position: absolute;
top: -7px;
left: -5px;
cursor: pointer;
opacity: 0; /*hide this*/
z-index: 2; /*and place it over the hamburger*/
-webkit-touch-callout: none;
}
/*Just a quick hamburger*/
#menuToggle span
{
display: block;
width: 33px;
height: 4px;
margin-bottom: 5px;
position: relative;
background: #cdcdcd;
border-radius: 3px;
z-index: 1;
transform-origin: 4px 0px;
transition: transform 0.5s cubic-bezier(0.77,0.2,0.05,1.0),
background 0.5s cubic-bezier(0.77,0.2,0.05,1.0),
opacity 0.55s ease;
}
#menuToggle span:first-child
{
transform-origin: 0% 0%;
}
#menuToggle span:nth-last-child(2)
{
transform-origin: 0% 100%;
}
/*Transform all the slices of hamburger into a crossmark*/
#menuToggle input:checked ~ span
{
opacity: 1;
transform: rotate(45deg) translate(-2px, -1px);
background: #232323;
}
/*But let's hide the middle one*/
#menuToggle input:checked ~ span:nth-last-child(3)
{
opacity: 0;
transform: rotate(0deg) scale(0.2, 0.2);
}
/*Ohyeah and the last one should go the other direction*/
#menuToggle input:checked ~ span:nth-last-child(2)
{
opacity: 1;
transform: rotate(-45deg) translate(0, -1px);
}
/*Make this absolute positioned at the top left of the screen*/
#menu
{
position: absolute;
width: 300px;
margin: -100px 0 0 0;
padding: 50px;
padding-top: 125px;
right: -100px;
background: #ededed;
list-style-type: none;
-webkit-font-smoothing: antialiased;
/*to stop flickering of text in safari*/
transform-origin: 0% 0%;
transform: translate(100%, 0);
transition: transform 0.5s cubic-bezier(0.77,0.2,0.05,1.0);
}
#menu li
{
padding: 10px 0;
font-size: 22px;
}
/*And let's fade it in from the left*/
#menuToggle input:checked ~ ul
{
transform: scale(1.0, 1.0);
opacity: 1;
}
<!-- Made by Erik Terwan -->
<!-- 24th of November 2015 -->
<!-- MIT License -->
<nav role='navigation'>
<div id="menuToggle">
<!--
A fake / hidden checkbox is used as click reciever,
so you can use the :checked selector on it.
-->
<input type="checkbox" />
<!--
Some spans to act as a hamburger.
They are acting like a real hamburger,
not that McDonalds stuff.
-->
<span></span>
<span></span>
<span></span>
<!--
Too bad the menu has to be inside of the button
but hey, it's pure CSS magic.
-->
<ul id="menu">
<li>Home</li>
<li>About</li>
<li>Info</li>
<li>Contact</li>
<li>Show me more</li>
</ul>
</div>
</nav>
After endless tryouts, I find myself completely unable to set the height of the side navbar to 100% and change the width according to the screen size.
What am I missing? What cannot I see? I would extremely appreciate any kind of help.
Thank you in advance and cheers!
This is the solution:
#menu
{
position: absolute;
height: 100vh;
width: 50vw;
margin: -100px 0 0 0;
padding: 50px;
padding-top: 125px;
right: -100px;
background: #ededed;
list-style-type: none;
-webkit-font-smoothing: antialiased;
/* to stop flickering of text in safari */
transform-origin: 0% 0%;
transform: translate(100%, 0);
transition: transform 0.5s cubic-bezier(0.77,0.2,0.05,1.0);
}
if you use: vh - vw instead of the % everything should work fine.
this works because it'll only fill up 100% of the height or 50% of the viewport, and not the parent.
Adding height: 100vh to your #menu css tells the container to fill 100% of the viewport height. If you change from the fixed-width of width: 300px to width: 25vw for example, your menu will only ever occupy 25% of the viewport width.
body
{
margin: 0;
padding: 0;
/*make it look decent enough*/
background: #232323;
color: #cdcdcd;
font-family: "Avenir Next", "Avenir", sans-serif;
overflow-x: hidden; /*needed because hiding the menu on the right side is not perfect*/
}
a
{
text-decoration: none;
color: #232323;
transition: color 0.3s ease;
}
a:hover
{
color: tomato;
}
#menuToggle
{
display: block;
position: absolute;
top: 50px;
right: 50px;
z-index: 1;
-webkit-user-select: none;
user-select: none;
}
#menuToggle input
{
display: block;
width: 40px;
height: 32px;
position: absolute;
top: -7px;
left: -5px;
cursor: pointer;
opacity: 0; /*hide this*/
z-index: 2; /*and place it over the hamburger*/
-webkit-touch-callout: none;
}
/*Just a quick hamburger*/
#menuToggle span
{
display: block;
width: 33px;
height: 4px;
margin-bottom: 5px;
position: relative;
background: #cdcdcd;
border-radius: 3px;
z-index: 1;
transform-origin: 4px 0px;
transition: transform 0.5s cubic-bezier(0.77,0.2,0.05,1.0),
background 0.5s cubic-bezier(0.77,0.2,0.05,1.0),
opacity 0.55s ease;
}
#menuToggle span:first-child
{
transform-origin: 0% 0%;
}
#menuToggle span:nth-last-child(2)
{
transform-origin: 0% 100%;
}
/*Transform all the slices of hamburger into a crossmark*/
#menuToggle input:checked ~ span
{
opacity: 1;
transform: rotate(45deg) translate(-2px, -1px);
background: #232323;
}
/*But let's hide the middle one*/
#menuToggle input:checked ~ span:nth-last-child(3)
{
opacity: 0;
transform: rotate(0deg) scale(0.2, 0.2);
}
/*Ohyeah and the last one should go the other direction*/
#menuToggle input:checked ~ span:nth-last-child(2)
{
opacity: 1;
transform: rotate(-45deg) translate(0, -1px);
}
/*Make this absolute positioned at the top left of the screen*/
#menu
{
position: absolute;
width: 25vw;
height: 100vh;
margin: -100px 0 0 0;
padding: 50px;
padding-top: 125px;
right: -100px;
background: #ededed;
list-style-type: none;
-webkit-font-smoothing: antialiased;
/*to stop flickering of text in safari*/
transform-origin: 0% 0%;
transform: translate(100%, 0);
transition: transform 0.5s cubic-bezier(0.77,0.2,0.05,1.0);
}
#menu li
{
padding: 10px 0;
font-size: 22px;
}
/*And let's fade it in from the left*/
#menuToggle input:checked ~ ul
{
transform: scale(1.0, 1.0);
opacity: 1;
}
<!-- Made by Erik Terwan -->
<!-- 24th of November 2015 -->
<!-- MIT License -->
<nav role='navigation'>
<div id="menuToggle">
<!--
A fake / hidden checkbox is used as click reciever,
so you can use the :checked selector on it.
-->
<input type="checkbox" />
<!--
Some spans to act as a hamburger.
They are acting like a real hamburger,
not that McDonalds stuff.
-->
<span></span>
<span></span>
<span></span>
<!--
Too bad the menu has to be inside of the button
but hey, it's pure CSS magic.
-->
<ul id="menu">
<li>Home</li>
<li>About</li>
<li>Info</li>
<li>Contact</li>
<li>Show me more</li>
</ul>
</div>
</nav>

Responsive animated navigation

I had codyhouse's css animations tutorial which was really nice. We wrote this navigation menu and I wanted to tweak it further to my likes.
I guess I'm trying to show the navigation links on screens that are bigger than 640px and make it invisible (like this current state) on all other screen sizes.
Codepen
var navTrigger = document.getElementsByClassName('nav-trigger')[0],
body = document.getElementsByTagName('body')[0];
navTrigger.addEventListener('click', toggleNavigation);
function toggleNavigation(event) {
event.preventDefault();
body.classList.toggle('nav-open');
}
*, *::after, *::before {
box-sizing: border-box;
}
body {
font-family: sans-serif;
line-height: 1;
margin: 0;
width: 100%;
height: 100%;
background: #333;
}
main {
position: relative;
z-index: 1;
height: 100vh;
overflow: hidden;
transition: transform .5s;
box-shadow: 0 0 50px #000;
}
.nav-open main {
transform: scale(.8)
}
.intro {
height: 100vh;
width: 100%;
display: table;
background: #f3f3f3;
}
h1 {
display: table-cell;
vertical-align: middle;
text-align: center;
font-size: 45px;
color: #ddd;
}
.nav-trigger {
position: fixed;
z-index: 4;
top: 40px;
right: 40px;
height: 44px;
width: 44px;
overflow: hidden;
color: transparent;
white-space: nowrap;
text-indent: 100%;
}
.nav-trigger span,
.nav-trigger span::before,
.nav-trigger span::after {
position: absolute;
height: 4px;
width: 36px;
background: #111;
transition: all .3s;
}
.nav-trigger span {
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.nav-trigger span::before,
.nav-trigger span::after {
content: '';
top: 0;
left: 0;
}
.nav-trigger span::before {
transform: translateY(-12px);
}
.nav-trigger span::after {
transform: translateY(12px);
}
.nav-trigger:hover span,
.nav-trigger:hover span::before,
.nav-trigger:hover span::after {
background: #888;
}
.nav-open .nav-trigger span {
background: transparent;
}
.nav-open .nav-trigger span::before,
.nav-open .nav-trigger span::after {
background: #888;
}
.nav-open .nav-trigger span::before {
transform: rotate(-45deg);
}
.nav-open .nav-trigger span::after {
transform: rotate(45deg);
}
.overlay {
position: fixed;
z-index: 2;
top: 0;
left: 0;
height: 100%;
width: 100%;
background: #333;
opacity: 0;
visibility: hidden;
transition: all .5s;
}
.nav-open .overlay {
opacity: .5;
visibility: visible;
}
.nav-container {
position: fixed;
z-index: 3;
top: 0;
right: 0;
height: 100%;
width: 100%;
padding: 3em 3.5em;
background: #343434;
overflow: auto;
transform: translateZ(0);
transform: translateY(-100%);
transition: transform .5s cubic-bezier(.07,.23,.34,1);
}
.nav-open .nav-container {
transform: translateX(0);
}
.nav {
list-style: none;
padding: 0;
}
.nav a {
display: block;
padding: .6em 0;
font-size: 30px;
font-family: bold;
font-family: sans-serif;
text-decoration: none;
color: #747474;
transform: translateZ(0);
}
.nav-open .nav a {
animation: slide-in .4s .2s backwards;
}
.nav-open .nav li:nth-of-type(2) a {
animation-delay: .3s;
}
.nav-open .nav li:nth-of-type(3) a {
animation-delay: .4s;
}
.nav-open .nav li:nth-of-type(4) a {
animation-delay: .5s;
}
.nav-open .nav li:nth-of-type(5) a {
animation-delay: .6s;
}
.nav li {
text-align: center;
}
#keyframes slide-in {
0% {
opacity: 0;
transform: translateY(-20px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
#media only screen and (min-width : 640px) {
/* .nav-trigger {
visibility: hidden;
} */
/* .nav li {
display: inline-block;
z-index: 60;
} */
}
<body>
<a href="#navigation" class="nav-trigger">
Menu<span></span>
</a>
<main>
<section class="intro">
<h1>Final Project</h1>
</section>
</main>
<nav class="nav-container" id="navigation">
<ul class="nav">
<li>Work</li>
<li>About</li>
<li>Contact</li>
</ul>
</nav>
<div class="overlay"></div>
</body>

Problems with menu

Is there a way so that when I open my menu, it does not go beyond the first section or scrolling will be disabled once the menu is open? I tried giving every section z-index 999 but that does not work
HTML:
<section class="intro">
<label>
<input type="checkbox">
<span class="menu">
<span class="hamburger"></span>
</span>
<ul>
<li>
Home
</li>
<li>
About
</li>
<li>
Contact
</li>
</ul>
</label>
<div class="text">
<h1>my<br>example<br>text</h1>
</div>
</div>
</section>
<section class="first">
</section>
<section class="second">
</section>
<section class="third">
</section>
CSS:
/* Section styling */
body, html {
height: 100%;
margin: 0;
}
* {
box-sizing: border-box;
}
section {
width: 100%;
display: table;
margin: 0;
max-width: none;
height: 100vh;
}
.intro {
background-color:#291411;
}
.first {
background-color:#834940;
}
.second {
background-color:#291411;
}
.third {
background-color:#834940;
}
/* Hide scrollbars */
html {
overflow: scroll;
overflow-x: hidden;
}
::-webkit-scrollbar {
width: 0px;
background: transparent;
}
::-webkit-scrollbar-thumb {
background: #FF0000;
}
/* Menu before */
label .hamburger {
position: absolute;
top: 135px;
left: 50px;
width: 30px;
height: 2px;
background: #291411;
display: block;
-webkit-transform-origin: center;
transform-origin: center;
-webkit-transition: .5s ease-in-out;
transition: .5s ease-in-out;
}
label .hamburger:after, label .hamburger:before {
-webkit-transition: .5s ease-in-out;
transition: .5s ease-in-out;
content: "";
position: absolute;
display: block;
width: 100%;
height: 100%;
background: #291411;
}
label .hamburger:before { top: -10px; }
label .hamburger:after { bottom: -10px; }
label input { display: none; }
label input:checked + .menu {
box-shadow: 0 0 0 100vw #E0C9B7, 0 0 0 100vh #E0C9B7;
border-radius: 0;
}
label input:checked + .menu .hamburger {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
label input:checked + .menu .hamburger:after {
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
bottom: 0;
}
label input:checked + .menu .hamburger:before {
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
top: 0;
}
label input:checked + .menu + ul { opacity: 1; }
/* Menu after */
label .menu {
position: absolute;
right: -100px;
top: -100px;
z-index: 100;
width: 200px;
height: 200px;
background: #E0C9B7;
border-radius: 50% 50% 50% 50%;
-webkit-transition: .5s ease-in-out;
transition: .5s ease-in-out;
box-shadow: 0 0 0 0 #E0C9B7, 0 0 0 0 #E0C9B7;
cursor: pointer;
}
label ul {
z-index: 200;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
opacity: 0;
-webkit-transition: .25s 0s ease-in-out;
transition: .25s 0s ease-in-out;
list-style-type:none;
}
label a {
margin-bottom: 1em;
display: block;
color: #291411;
text-decoration: none;
}
/* Footer styling */
footer {
padding: 1% 5%;
text-align:center;
background-color: #291411;
color: #E0C9B7;
}
To disable the scroll when the menu is open I tried to add overflow-x:hidden to the html and body but this makes the whole page weird
Did a simple solution with jquery, you can do this with javascript. I used jquery just to save time.
$(".js-change").on("change", function() {
$("html").toggleClass("menu-open");
});
/* Section styling */
body, html {
height: 100%;
margin: 0;
}
* {
box-sizing: border-box;
}
section {
width: 100%;
display: table;
margin: 0;
max-width: none;
height: 100vh;
}
.intro {
background-color:#291411;
}
.first {
background-color:#834940;
}
.second {
background-color:#291411;
}
.third {
background-color:#834940;
}
/* Hide scrollbars */
html {
overflow: scroll;
overflow-x: hidden;
}
::-webkit-scrollbar {
width: 0px;
background: transparent;
}
::-webkit-scrollbar-thumb {
background: #FF0000;
}
/* Menu before */
label .hamburger {
position: absolute;
top: 135px;
left: 50px;
width: 30px;
height: 2px;
background: #291411;
display: block;
-webkit-transform-origin: center;
transform-origin: center;
-webkit-transition: .5s ease-in-out;
transition: .5s ease-in-out;
}
label .hamburger:after, label .hamburger:before {
-webkit-transition: .5s ease-in-out;
transition: .5s ease-in-out;
content: "";
position: absolute;
display: block;
width: 100%;
height: 100%;
background: #291411;
}
label .hamburger:before { top: -10px; }
label .hamburger:after { bottom: -10px; }
label input { display: none; }
label input:checked + .menu {
box-shadow: 0 0 0 100vw #E0C9B7, 0 0 0 100vh #E0C9B7;
border-radius: 0;
}
label input:checked + .menu .hamburger {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
label input:checked + .menu .hamburger:after {
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
bottom: 0;
}
label input:checked + .menu .hamburger:before {
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
top: 0;
}
label input:checked + .menu + ul { opacity: 1; }
/* Menu after */
label .menu {
position: absolute;
right: -100px;
top: -100px;
z-index: 100;
width: 200px;
height: 200px;
background: #E0C9B7;
border-radius: 50% 50% 50% 50%;
-webkit-transition: .5s ease-in-out;
transition: .5s ease-in-out;
box-shadow: 0 0 0 0 #E0C9B7, 0 0 0 0 #E0C9B7;
cursor: pointer;
}
label ul {
z-index: 200;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
opacity: 0;
-webkit-transition: .25s 0s ease-in-out;
transition: .25s 0s ease-in-out;
list-style-type:none;
}
label a {
margin-bottom: 1em;
display: block;
color: #291411;
text-decoration: none;
}
/* Footer styling */
footer {
padding: 1% 5%;
text-align:center;
background-color: #291411;
color: #E0C9B7;
}
.menu-open,
.menu-open body {
overflow:hidden;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<section class="intro">
<label>
<input type="checkbox" class="js-change">
<span class="menu">
<span class="hamburger"></span>
</span>
<ul>
<li>
Home
</li>
<li>
About
</li>
<li>
Contact
</li>
</ul>
</label>
<div class="text">
<h1>my<br>example<br>text</h1>
</div>
</div>
</section>
<section class="first">
</section>
<section class="second">
</section>
<section class="third">
</section>

How to avoid large padding between nav dropdown menu and rest of the page?

So what I need to do might be simple but I have no clue after long hours of research.
I want to make my page shifting down when I am hovering on my dropdown menu. (if this is not possible) I would like to avoid a big padding between my HEADER and the rest of my page, SECTION>TITLE...
Is there any chance to do so without using any jQuery or JavaScript?
Many thanks for your time and patience.
HTML code:
<html lang="en">
<head>
<meta charset="utf-8"></meta>
<title>Emblem Collectible Books</title>
<link rel="stylesheet" href="css/style.css" media="all">
<meta name="viewport" content="width=device-width, initial-scale=1.0"></meta>
<script src="shifter.js"></script>
</head>
<body>
<div id="page">
<header id="pageheader" role="banner">
<div id="commonlink">
<nav id="commonlinkbar">
<ul>
<li>Contact us</li>
<li>Accessibility</li>
<li>Login</li>
</ul>
</nav>
</div>
<div id="logo">
<div class="innerlogo">
<img src="images/logo.png" alt="logo">
</div>
</div>
<div id="mainnav">
<div id="navwrapper">
<nav id="primary" role="navigation">
<ul>
<li class="navbar">Home</li><li class="dropdown">
Books
<ul>
<li>20th Century Books</li>
<li>19th Century Books</li>
<li>18th Century Books</li>
<li>Rare Books</li>
</ul></li><li>
Delivery</li><li>
About</li><li>
Books as an Investment</li>
</ul>
</nav>
</div>
</div>
</header>
<main id="mainc" role="main">
<section id="introduction" role="introduction">
<div id="title">
<h1>Welcome to <span class="titleintro">Emblem</span>, Rare collectible Books</h1>
</div>**
Here is the css
/* Embed the fonts before anything else */
#font-face {
font-family: 'parisr';
src:url("../fonts/parisr.eot?#iefix") format("embedded-opentype"),
url("../fonts/parisr.woff") format("woff"),
url("../fonts/parisr.ttf") format("truetype"),
url("../fonts/parisr.svg#parisr") format("svg");
font-weight: normal;
font-style: normal;
}
/* Page Styling */
#page {
width: 100%;
margin: 0 auto;
}
#pageheader {
overflow: hidden;
padding-top: 1%;
width: 100%;
height: 455px;
}
/* Common links styling */
#commonlink{
float: right;
padding-left: 4%;
width: 30%;
}
/* Commmon link bar */
#commonlinkbar{
margin: 0 auto;
padding: 0;
max-width: 100%;
font-family: Verdana, Geneva, sans-serif;
}
#commonlinkbar li a{
font-size: 1em;
color: #236841;
font-family: Verdana, Geneva, sans-serif;
padding-bottom: 5%;
}
#commonlinkbar ul li{
display: inline-block;
background-color: #ffffff;
padding: 2%;
position: relative;
}
#commonlink ul li :hover:before{
content: "";
position: absolute;
width: 100%;
height: 2px;
bottom: 0;
left: 0;
background-color: #236841;
visibility: visible;
-webkit-transform: scaleX(1);
transform: scaleX(1);
-webkit-transition: all 0.3s ease-in-out 0s;
transition: all 0.3s ease-in-out 0s;
}
#commonlink ul li a:before{
content: "";
position: absolute;
width: 100%;
height: 2px;
bottom: 0;
left: 0;
background-color: #236841;
visibility: hidden;
-webkit-transform: scaleX(0);
transform: scaleX(0);
-webkit-transition: all 0.3s ease-in-out 0s;
transition: all 0.3s ease-in-out 0s;
}
#commonlink ul li a:hover{
color: #309c64;
}
/* Logo */
#logo{
max-width: 100%;
margin-bottom: 2%;
}
.innerlogo{
width: 55%;
padding: 0% 20%;
}
.innerlogo img{
max-width: 100%;
}
/* Main navigation bar styling */
#mainnav{
width: 100%;
}
#navwrapper{ /* Navigation bar position */
width: 66%;
height: auto;
margin: 0 auto;
text-align: left;
float: right;
padding: 0% 14%;
}
#mainnav ul{
list-style-type: none;
padding: 0;
margin: 0;
position: relative;
}
#mainnav ul li{ /* Navigation bar border design */
display: inline-block;
background-color: #236841;
border-left-color: #3cc37d;
border-left-width: 5px;
border-left-style: inset;
border-right-color: #ffffff;
border-right-width: 5px;
border-right-style: solid;
border-radius: 0 10px 0px 0;
}
#mainnav li a{
font-size: 1.5em;
font-family: 'parisr', Verdana, Geneva, sans-serif;
}
#mainnav ul li:hover{
background-color: #ffffff;
animation: bounce 1s;
}
#mainnav ul li a,visited{
color: #000;
display: block;
padding: 10px;
text-decoration: none;
}
#mainnav ul li a:hover{ /* Navigation bar bounce effect */
color: #236841;
text-decoration: none;
border-right-color: #236841;
border-right-width: 5px;
border-right-style: solid;
border-radius: 0 20px 20px 0;
animation: bounce 1s;
-webkit-animation-name: bounceOutUp;
animation-name: bounceOutUp;
-webkit-animation-duration: 1.5s;
animation-duration: 1.5s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
#-webkit-keyframes bounceOutUp {
20% {
-webkit-transform: translate3d(0, -10px, 0);
transform: translate3d(0, -10px, 0);
}
40%, 45% {
opacity: 1;
-webkit-transform: translate3d(0, 20px, 0);
transform: translate3d(0, 20px, 0);
}
100% {
opacity: 0;
-webkit-transform: translate3d(0, -2000px, 0);
transform: translate3d(0, -2000px, 0);
}
}
#keyframes bounceOutUp {
20% {
-webkit-transform: translate3d(0, -10px, 0);
transform: translate3d(0, -10px, 0);
}
40%, 45% {
opacity: 1;
-webkit-transform: translate3d(0, 20px, 0);
transform: translate3d(0, 20px, 0);
}
100% {
opacity: 0;
-webkit-transform: translate3d(0, -2000px, 0);
transform: translate3d(0, -2000px, 0);
}
}
#mainnav ul li:hover ul{ /* Navigation bar dropdown menu design */
display: inline-block;
color: #236841;
}
#mainnav ul ul{
color: #fff;
display: none;
position: absolute;
background-color: #fff;
}
#mainnav ul ul li{
display: block;
margin: 2px 0px 2px 0px;
}
#mainnav ul ul li a,visited{
color: #fff;
}
#mainnav ul ul li:hover{ /* Navigation bar dropdown menu bounce effect */
color: #236841;
-webkit-animation-name: bounceOutRight;
animation-name: bounceOutRight;
-webkit-animation-duration: 1.5s;
animation-duration: 1.5s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
#-webkit-keyframes bounceOutRight {
20% {
opacity: 1;
-webkit-transform: translate3d(-20px, 0, 0);
transform: translate3d(-20px, 0, 0);
}
100% {
opacity: 0;
-webkit-transform: translate3d(2000px, 0, 0);
transform: translate3d(2000px, 0, 0);
}
}
#keyframes bounceOutRight {
20% {
opacity: 1;
-webkit-transform: translate3d(-20px, 0, 0);
transform: translate3d(-20px, 0, 0);
}
100% {
opacity: 0;
-webkit-transform: translate3d(2000px, 0, 0);
transform: translate3d(2000px, 0, 0);
}
}
/* breadcrumbs */
#breadcrumbs{
width: auto;
padding: 1%;
}
#breadcrumbs a{
color: #000;
font-style: italic;
}
/* Main content style */
#mainc{
overflow: hidden;
width: 100%;
padding-bottom: 50px;
}
/* Section Introduction style */
#introduction{
width: 90%;
max-width: 100%;
padding: 0% 5% 0% 5%;
}
/* Title page style */
#title{
max-width: 100%;
padding: 0% 10%;
}
try this.
make a div the size you need
add to css
myDiv {
display: none;
}
a:hover + myDiv {
display: block;
}
Remove or adjust the declared height of the header div....
#pageheader {
overflow: hidden;
padding-top: 1%;
width: 100%;
height: 455px; /* <-- either remove this line or change it to something correct */
}
Based on the pieces you've supplied, it seems that height is the bulk of the header. If you want it smaller, you need to change or remove that declaration.
Removing it would allow the header div to be whatever automatic height is needed to display the contents within the div which are not set as floats.

#media transform an off canvas nav

I am attempting to transform an off canvas nav once the screen size hits a width of 600px. I have the nav bar toggled with a button that appears at 600px or less. I am trying to get the nav to close if you resize the screen to a width over 600px and then reopen iff the nav was already opened before resizing the screen. The ".show-nav #site-canvas" clauses in the two #media break points don't seem to do anything and i'm not sure why.
Here is the css
#media screen and (min-width: 601px)
{
.toggle-nav
{
display: none;
}
#nav
{
display: block;
}
.show-nav #site-canvas
{
-webkit-transform: translateX(0);
transform: translateX(0);
}
}
#media screen and (max-width: 600px)
{
.toggle-nav
{
display: block;
}
#nav
{
display: none;
}
.show-nav #site-canvas
{
-webkit-transform: translateX(300px);
transform: translateX(300px);
}
}
#site-wrapper
{
position: relative;
overflow: hidden;
width: 100%;
}
#site-canvas
{
width: 100%;
height: 100%;
position: relative;
-webkit-transform: translateX(0);
transform: translateX(0);
-webkit-transition: 300ms ease all;
transition: 300ms ease all;
}
#site-menu
{
width: 300px;
height: 100%;
position: absolute;
top: 0;
left: -320px;
background: black;
}
#site-menu > .nav-pills > li
{
padding-left: 15px;
width: 100%;
list-style-type: none;
border-radius: 5px;
border: 1px solid whitesmoke;
}
#site-menu > .nav-pills > a
{
display: block;
}
.show-nav #site-canvas
{
-webkit-transform: translateX(300px);
transform: translateX(300px);
}
Change your css order Try this CSS
#site-wrapper
{
position: relative;
overflow: hidden;
width: 100%;
}
#site-canvas
{
width: 100%;
height: 100%;
position: relative;
-webkit-transform: translateX(0);
transform: translateX(0);
-webkit-transition: 300ms ease all;
transition: 300ms ease all;
}
#site-menu
{
width: 300px;
height: 100%;
position: absolute;
top: 0;
left: -320px;
background: black;
}
#site-menu > .nav-pills > li
{
padding-left: 15px;
width: 100%;
list-style-type: none;
border-radius: 5px;
border: 1px solid whitesmoke;
}
#site-menu > .nav-pills > a
{
display: block;
}
.show-nav #site-canvas
{
-webkit-transform: translateX(300px);
transform: translateX(300px);
}
#media screen and (min-width: 601px)
{
.toggle-nav
{
display: none;
}
#nav
{
display: block;
}
.show-nav #site-canvas
{
-webkit-transform: translateX(0);
transform: translateX(0);
}
}
#media screen and (max-width: 600px)
{
.toggle-nav
{
display: block;
}
#nav
{
display: none;
}
.show-nav #site-canvas
{
-webkit-transform: translateX(300px);
transform: translateX(300px);
}
}