The navbar responsive issue when I resize the browser width - html

The Burger bar animation & nav tag doesn't work when I resize the browser width. But when I refresh the page it shows and works. So I need to refresh the page every time when I resize the window width to make it work.
I code with Bootstrap v5.2 and jQuery.I have struggled with this problem for a while. Please help me up.
Many Thanks.
/*navigation icon animation*/
let trigger = 'X';
jQuery(document).ready(function() {
$('#toggle-menu').click(function() {
trigger = 'X';
$(this).toggleClass('menu-is-active')
});
/* click outside of nav to trigger navigation icon animation*/
$(document).click(function() {
if (trigger == 'X') {
$("#toggle-menu").toggleClass();
trigger = 'ham';
}
});
$("nav").click(function(e) {
e.stopPropagation();
return false;
});
});
/*toggle Nav menu Background up & down*/
if ($(window).width() <= 768) {
$('#toggle-menu').on('click', function() {
if ($('.nav').is(':visible')) {
$('.nav').animate({
height: '0'
}, function() {
$(this).hide();
});
} else {
$('.nav').show();
$('.nav').animate({
height: '180'
});
}
});
}
/* Click outside of nav to close Toggle*/
if ($(window).width() <= 768) {
$(document).click(function() {
$(".nav").hide();
});
$("#toggle-menu").click(function(e) {
e.stopPropagation();
return false;
});
}
/*-- Nav Bar --*/
header a {
color: #ffffff;
text-decoration: none;
}
header a:focus,
a:hover {
color: #a7a7a7;
}
header a:active {
color: #b8b8b8;
}
header {
display: flex;
height: 40px;
justify-content: space-between;
align-items: center;
padding: 0px 10px;
position: relative;
z-index: 2;
}
.logo {
float: left;
cursor: pointer;
text-decoration: none;
}
.nav {
float: right;
}
.nav>li {
display: inline-block;
padding-right: 20px;
font-size: 0.9rem;
}
.nav>li:last-child {
padding-right: 10px;
}
.hover-underline-animation {
display: inline-block;
position: relative;
color: white;
text-decoration: none;
}
.hover-underline-animation:after {
content: '';
position: absolute;
width: 100%;
transform: scaleX(0);
height: 1.5px;
bottom: -3px;
left: 0;
background-color: #f0bc1f;
transform-origin: bottom right;
transition: transform 0.3s ease-out;
}
.hover-underline-animation:hover:after {
transform: scaleX(1);
transform-origin: bottom left;
}
.language {
text-decoration: none;
color: #ffffff;
}
.header-divider {
position: absolute;
border-top: 1.5px solid white;
width: 50%;
z-index: 2;
right: 0px;
top: 25px;
opacity: 0.3;
}
#media (max-width: 768px) {
.nav {
position: fixed;
width: 100%;
text-align: center;
display: none;
background-color: #d3d3d33f;
left: 0px;
top: 39px;
}
.nav li:hover {
background-color: #f0bc1f;
transition: ease-in-out;
}
.nav li a:hover {
color: #000000;
}
.nav>li {
display: block;
float: center;
padding: 8px 0px;
}
.nav>li:last-child {
border-bottom: none;
}
.hover-underline-animation {
display: block;
position: relative;
color: white;
text-decoration: none;
}
.hover-underline-animation:hover {
background-color: #f0bc1f;
}
.hover-underline-animation:after {
content: '';
position: absolute;
display: none;
}
/*--- logo ---*/
.logo {
float: left;
display: block;
cursor: pointer;
}
/*--- Navigation Burger Menu ---*/
#toggle-menu {
float: right;
display: block;
cursor: pointer;
margin-right: 20px;
}
#toggle-menu div {
width: 15px;
height: 15px;
position: relative;
}
#toggle-menu .bar {
padding: 0;
width: 25px;
height: 3px;
background-color: rgb(255, 255, 255);
display: block;
border-radius: 3px;
transition: all 0.4s ease-in-out;
position: absolute;
}
#toggle-menu span.bar1 {
top: 0px;
}
#toggle-menu span.bar2,
.bar3 {
top: 8px;
}
#toggle-menu span.bar4 {
top: 16px;
}
/*--- Burger Menu Animation---*/
#toggle-menu.menu-is-active .bar {
padding: 0;
width: 25px;
height: 3px;
background-color: rgb(255, 255, 255);
display: block;
border-radius: 3px;
transition: all 0.4s ease-in-out;
position: absolute;
}
#toggle-menu.menu-is-active span.bar1 {
top: 0px;
-webkit-transform: translateX(20px);
-moz-transform: translateX(20px);
transform: translateX(20px);
background-color: transparent;
}
#toggle-menu.menu-is-active span.bar4 {
top: 16px;
-webkit-transform: translateX(-20px);
-moz-transform: translateX(-20px);
transform: translateX(-20px);
background-color: transparent;
}
#toggle-menu.menu-is-active span.bar2 {
top: 8px;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
transform: rotate(45deg);
}
#toggle-menu.menu-is-active span.bar3 {
top: 8px;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
transform: rotate(-45deg);
}
}
<header class="container-fluid bg-dark">
CCH
<a id="toggle-menu">
<div id="barcontainer">
<span class="bar bar1"></span>
<span class="bar bar2"></span>
<span class="bar bar3"></span>
<span class="bar bar4"></span>
</div>
</a>
<ul class="nav">
<li>Home</li>
<li>About us</li>
<li>Service</li>
<li>Contact</li>
<li>Career</li>
<li>中文/En</li>
</ul>
</header>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

The issue with your current code is because you only check the window widths when the page loads, not when it resizes.
That being said you can make the code much more simple by toggling a class on the button. You can then use CSS transitions to animate the state of the menu based on the #media rules.
The only thing that's required in JS to make this work is to remove the class from the burger when the screen resizes in order to hide the menu once more.
jQuery($ => {
$('#toggle-menu').on('click', e => {
$(e.currentTarget).toggleClass('menu-is-active')
});
});
$(window).on('resize', () => {
$('#toggle-menu').removeClass('menu-is-active');
});
body {
background-color: #333;
}
header a {
color: #ffffff;
text-decoration: none;
}
header a:focus,
a:hover {
color: #a7a7a7;
}
header a:active {
color: #b8b8b8;
}
header {
display: flex;
height: 40px;
justify-content: space-between;
align-items: center;
padding: 0px 10px;
position: relative;
z-index: 2;
}
.logo {
float: left;
cursor: pointer;
text-decoration: none;
}
.nav {
float: right;
}
.nav.show {
display: block;
}
.nav>li {
display: inline-block;
padding-right: 20px;
font-size: 0.9rem;
}
.nav>li:last-child {
padding-right: 10px;
}
.hover-underline-animation {
display: inline-block;
position: relative;
color: white;
text-decoration: none;
}
.hover-underline-animation:after {
content: '';
position: absolute;
width: 100%;
transform: scaleX(0);
height: 1.5px;
bottom: -3px;
left: 0;
background-color: #f0bc1f;
transform-origin: bottom right;
transition: transform 0.3s ease-out;
}
.hover-underline-animation:hover:after {
transform: scaleX(1);
transform-origin: bottom left;
}
.language {
text-decoration: none;
color: #ffffff;
}
.header-divider {
position: absolute;
border-top: 1.5px solid white;
width: 50%;
z-index: 2;
right: 0px;
top: 25px;
opacity: 0.3;
}
#media (max-width: 768px) {
.nav {
position: fixed;
width: 100%;
text-align: center;
opacity: 0;
background-color: #d3d3d33f;
left: 0px;
top: 39px;
height: 0;
transition: height 0.25s, opacity 0.25s;
}
#toggle-menu.menu-is-active + ul.nav {
opacity: 1;
height: 200px;
}
.nav li:hover {
background-color: #f0bc1f;
transition: ease-in-out;
}
.nav li a:hover {
color: #000000;
}
.nav>li {
display: block;
float: center;
padding: 8px 0px;
}
.nav>li:last-child {
border-bottom: none;
}
.hover-underline-animation {
display: block;
position: relative;
color: white;
text-decoration: none;
}
.hover-underline-animation:hover {
background-color: #f0bc1f;
}
.hover-underline-animation:after {
content: '';
position: absolute;
display: none;
}
/*--- logo ---*/
.logo {
float: left;
display: block;
cursor: pointer;
}
/*--- Navigation Burger Menu ---*/
#toggle-menu {
float: right;
display: block;
cursor: pointer;
margin-right: 20px;
}
#toggle-menu div {
width: 15px;
height: 15px;
position: relative;
}
#toggle-menu .bar {
padding: 0;
width: 25px;
height: 3px;
background-color: rgb(255, 255, 255);
display: block;
border-radius: 3px;
transition: all 0.4s ease-in-out;
position: absolute;
}
#toggle-menu span.bar1 {
top: 0px;
}
#toggle-menu span.bar2,
.bar3 {
top: 8px;
}
#toggle-menu span.bar4 {
top: 16px;
}
/*--- Burger Menu Animation---*/
#toggle-menu.menu-is-active .bar {
padding: 0;
width: 25px;
height: 3px;
background-color: rgb(255, 255, 255);
display: block;
border-radius: 3px;
transition: all 0.4s ease-in-out;
position: absolute;
}
#toggle-menu.menu-is-active span.bar1 {
top: 0px;
-webkit-transform: translateX(20px);
-moz-transform: translateX(20px);
transform: translateX(20px);
background-color: transparent;
}
#toggle-menu.menu-is-active span.bar4 {
top: 16px;
-webkit-transform: translateX(-20px);
-moz-transform: translateX(-20px);
transform: translateX(-20px);
background-color: transparent;
}
#toggle-menu.menu-is-active span.bar2 {
top: 8px;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
transform: rotate(45deg);
}
#toggle-menu.menu-is-active span.bar3 {
top: 8px;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
transform: rotate(-45deg);
}
}
<header class="container-fluid bg-dark">
CCH
<a id="toggle-menu">
<div id="barcontainer">
<span class="bar bar1"></span>
<span class="bar bar2"></span>
<span class="bar bar3"></span>
<span class="bar bar4"></span>
</div>
</a>
<ul class="nav">
<li>Home</li>
<li>About us</li>
<li>Service</li>
<li>Contact</li>
<li>Career</li>
<li>中文/En</li>
</ul>
</header>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
Here's a working example in jsFiddle - it's easier to see the resize logic working here as you can drag the frames.

Related

*CSS Only* Images showing through open menu pane

I can't seem to get my open nav menu pane to display on top of the page content, mainly images. I've tried changing z-index but that only seems to make things worse.
Thanks for any help, this is for a school project (my first html/css class). I'm not sure if I need to also post the HTML here?
'''#import url('https://fonts.googleapis.com/css?family=Libre+Caslon+Text:400,700&display=swap');
body {
font-family: Libre Caslon Text;
background-color: #FFAB91;
}
.body-text {
padding-top: 20vh;
text-align: center;
position: relative;
}
.hamburger-icon {
position: absolute;
z-index: 1;
top: 5vh;
left: 5vw;
padding-bottom: 2vh;
}
.hamburger-icon span {
height: 5px;
width: 40px;
background-color: black;
display: block;
margin: 5px 0px 5px 0px;
transition: 0.7s ease-in-out;
transform: none;
}
#openmenu:checked~.menu-pane {
left: -5vw;
transform: translateX(-5vw);
}
#openmenu:checked~.body-text {
display: none;
}
#openmenu:checked~.hamburger-icon span:nth-of-type(2) {
transform: translate(0%, 175%) rotate(-45deg);
background-color: white;
}
#openmenu:checked~.hamburger-icon span:nth-of-type(3) {
transform: rotate(45deg);
background-color: white;
}
#openmenu:checked~.hamburger-icon span:nth-of-type(1) {
opacity: 0;
}
#openmenu:checked~.hamburger-icon span:nth-of-type(4) {
opacity: 0;
}
div.menu-pane {
background-color: #000;
position: absolute;
transform: translateX(-105vw);
transform-origin: (0, 0);
width: 100vw;
height: 100%;
transition: 0.6s ease-in-out;
}
.menu-pane p {
color: black;
font-size: 0.6em;
}
.menu-pane nav {
padding: 10%;
}
.menu-links li,
a,
span {
transition: 0.5s ease-in-out;
}
.menu-pane ul {
padding: 10%;
display: inline-block;
}
.menu-pane li {
padding-top: 20px;
padding-bottom: 20px;
margin-left: 10px;
font-size: 1em;
}
.menu-pane li:first-child {
font-size: 1.3em;
margin-left: -10px;
}
.menu-links li a {
color: white;
text-decoration: none;
}
.menu-links li:hover a {
color: #FFAB91;
}
.menu-links li:first-child:hover a {
color: black;
background-color: #FFAB91;
}
#eug-info {
background-color: #FFAB91;
border: 2px solid;
border-color: #FFAB91;
display: block;
opacity: 0;
}
.menu-links li:first-child:hover #eug-info {
opacity: 1;
}
.menu-links li:first-child:hover #spring-info {
opacity: 1;
}
#spring-info {
background-color: #FFAB91;
border: 2px solid;
border-color: #FFAB91;
display: block;
opacity: 0;
}
.menu-links li:first-child a {
padding: 5px;
}
input.hamburger-checkbox {
position: absolute;
z-index: 3;
top: 5vh;
left: 5vw;
width: 10vw;
opacity: 0;
height: 6vh;
}'''
Images showing through open menu pane

Why can I click the li when the navbar isn't showed?

Ok so I have a problem with my navbar on mobile. It is hidden and it displays only when I press the bar (toggler). The problem is: if I press on the screen when the navbar isn't displayed it still goes to the links, even if I can't see the li's.
I want to keep the same navbar but I don't want to acces the links when it is closed.
If its possible please tell me how to solve it and the problems of my navbar
This is my code:
.banner {
margin: 0px;
position: relative;
width: 100%;
height: 100vh;
background-size: cover;
background-image: linear-gradient(to left, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.6)), url(../img/pozabackground-home2.jpg);
background-position: center;
box-shadow: 1px 2px 4px 0px #00000075 !important;
background-attachment: fixed;
}
.navigatie {
background-color: transparent;
width: 100%;
position: fixed;
z-index: 99;
margin: 0px;
padding: 0px;
}
.logo {
float: left;
padding: 8px;
margin-left: 40px;
margin-top: 8px;
}
.navbar-brand {
color: white !important;
}
.navbar-brand img {
width: auto;
height: 100px;
margin: -32px 0px -25px 0px;
}
nav ul {
float: right;
list-style-type: none;
padding-top: 5px;
margin-right: 20px;
}
nav ul li {
float: left;
}
nav ul li:not(:first-child) {
margin-left: 48px;
}
nav ul li:last-child {
margin-right: 24px;
}
nav ul li a {
display: inline-block;
outline: none;
color: #fff;
text-transform: uppercase;
text-decoration: none;
font-size: 13px;
letter-spacing: 1.1px;
font-weight: 600;
}
nav ul li a:hover {
color: #fff;
text-decoration: underline;
}
/* FUNDAL JS */
.fundal {
background: #104f47 !important;
box-shadow: 1px 2px 4px 0px #00000075 !important;
}
.fundal .nav-btn {
background-color: #104f47;
border-radius: 50%;
box-shadow: 1px 2px 4px 0px #00000075;
}
.fundal .nav-btn i {
background: #fff;
border-radius: 2px;
}
#nav:checked+.nav-btn {
transform: rotate(45deg);
background-color: #104f47;
}
#nav:checked+.nav-btn i {
background: #fff;
transition: transform 0.2s ease;
}
#nav:checked+.nav-btn i:nth-child(1) {
transform: translateY(6px) rotate(180deg);
}
#nav:checked+.nav-btn i:nth-child(2) {
opacity: 0;
}
#nav:checked+.nav-btn i:nth-child(3) {
transform: translateY(-6px) rotate(90deg);
}
#nav:checked~.nav-wrapper {
z-index: 9990;
opacity: 1;
}
#nav:checked~.nav-wrapper ul li a {
opacity: 1;
transform: translateX(0);
}
.hidden {
display: none;
}
/* MEDIA SCREEN PTR TLF */
#media only screen and (max-width: 991px) {
.navigatie {
background-color: transparent;
width: 100%;
position: absolute;
;
z-index: 99;
margin: 0px;
padding: 0px;
}
.navbar-brand img {
height: 100px;
margin: -20px 0px 0px 0px;
}
.nav-wrapper {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
background: #fff;
opacity: 0;
transition: all 0.2s ease;
}
.nav-wrapper ul {
position: absolute;
top: 50%;
transform: translateY(-50%);
width: 100%;
}
.nav-wrapper ul li {
display: block;
float: none;
width: 100%;
text-align: right;
padding-top: 10px;
margin-bottom: 10px;
}
.nav-wrapper ul li:nth-child(1) a {
transition-delay: 0.2s;
}
.nav-wrapper ul li:nth-child(2) a {
transition-delay: 0.3s;
}
.nav-wrapper ul li:nth-child(3) a {
transition-delay: 0.4s;
}
.nav-wrapper ul li:nth-child(4) a {
transition-delay: 0.5s;
}
.nav-wrapper ul li:not(:first-child) {
margin-left: 0;
}
.nav-wrapper ul li a {
padding: 10px 24px;
opacity: 0;
color: #000;
font-size: 14px;
font-weight: 600;
letter-spacing: 1.2px;
transform: translateX(-20px);
transition: all 0.2s ease;
}
.nav-btn {
position: fixed;
right: 30px;
top: 28px;
display: block;
width: 48px;
height: 46px;
cursor: pointer;
z-index: 9999;
border-radius: 50%;
}
.nav-btn i {
display: block;
width: 20px;
height: 2px;
background: #fff;
border-radius: 2px;
margin-left: 14px;
}
.nav-btn i:nth-child(1) {
margin-top: 16px;
}
.nav-btn i:nth-child(2) {
margin-top: 4px;
opacity: 1;
}
.nav-btn i:nth-child(3) {
margin-top: 4px;
}
}
/* SCRIS DE LA BANNER */
.title {
position: absolute;
top: 47%;
left: 35%;
text-align: left;
transform: translate(-50%, -50%);
}
.title h1 {
color: #fff;
font-family: poppins;
font-size: 50px;
color: #f5f6f8;
padding-bottom: 20px;
}
.button button {
display: inline-block;
font-size: 12px;
text-transform: uppercase;
text-align: center;
padding: 13px 20px;
border: none;
color: white;
font-family: montserrat;
text-decoration: none;
transition: 0.6s ease;
background-color: #104f47;
box-shadow: 1px 2px 4px 0px #00000075;
outline: none;
}
.button button:hover {
background-color: #104f47;
color: white;
}
<div class="navigatie">
<nav>
<input type="checkbox" id="nav" class="hidden">
<label for="nav" class="nav-btn">
<i></i>
<i></i>
<i></i>
</label>
<div class="logo">
<a class="navbar-brand" href="index.php"><img src="./img/logoinainte.png"></a>
</div>
<div class="nav-wrapper">
<ul>
<li>Acasa</li>
<li>Despre</li>
<li>Servicii</li>
<li>Tarife</li>
<li>Contact</li>
</ul>
</div>
</nav>
</div>
<section class="banner">
<div class="container">
<div class="title">
<h1>Aspect curat <br>și îmbunătățit al <br>locuinței tale</h1>
<div class="button">
<button type="button">Sună acum!</button>
</div>
</div>
</div>
</section>
Could you tell me what is the problem?
You are using opacity. With opacity the element becomes invisible but it is still there. You have to set its display to none. And when the button is clicked you have to set its display to block.
.nav-wrapper {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
background: #fff;
display:none;
transition: all 0.2s ease;
}
#nav:checked ~ .nav-wrapper {
z-index: 9990;
display:block
}

CSS/HTML things. I can't resize my menu buttons for every screen

I am a beginner in using HTML/CSS, but I started by editing different things to catch as little as possible. I have a problem. I was helped by a friend to create a menu, but it does not increase/shrink/center on the right side after each monitor/phone from which the site is accessed.
I don't know what to do first.
HTML
<!-- /Main navigation -->
</div>
</nav>
<div class="home-wrapper">
<div class="container">
<div class="row">
<div class="col-md-10 col-md-offset-1">
<div class="home-content">
<h1 class="white-text"><b>Adrian Vichiriuc</b></h1>
</div>
</div>
</div>
</div>
</div>
</header>
<!-- /Header -->
<!-- Back to top -->
<div id="back-to-top"></div>
<!-- /Back to top -->
<!-- Preloader -->
<div id="preloader">
<div class="preloader">
<span></span>
<span></span>
<span></span>
<span></span>
</div>
</div>
<!-- /Preloader -->
<!-- jQuery Plugins -->
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/owl.carousel.min.js"></script>
<script type="text/javascript" src="js/jquery.magnific-popup.js"></script>
<script type="text/javascript" src="js/main.js"></script>
<!-- Footer -->
<style>
.footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
color: white;
text-align: center;
}
</style>
<div class="footer">
<p style="font-size:14px; color:#000000; font-weight:normal; text-align: center ">
COPYRIGHT © 2019. SITE CREAT DE <span style="color: #07B425; font-weight:bold">ADRIAN VICHIRIUC</span></p>
</div>
</body>
</html>
CSS
/*------------------------------------*\
General
\*------------------------------------*/
/* -- Buttons -- */
.main-btn, .white-btn, .outline-btn {
display: inline-block;
padding: 10px 35px;
margin: 3px;
border: 2px solid transparent;
border-radius: 3px;
-webkit-transition: 0.2s opacity;
transition: 0.2s opacity;
}
.main-btn {
background: #6195FF;
color: #FFF;
}
.white-btn {
background: #FFF;
color: #10161A !important;
}
.outline-btn {
background: transparent;
color: #6195FF !important;
border-color: #6195FF;
}
.main-btn:hover, .white-btn:hover, .outline-btn:hover {
opacity: 0.8;
}
/*------------------------------------*\
Logo
\*------------------------------------*/
.navbar-brand {
padding: 0;
}
.navbar-right {
float: right!important;
margin-right: -350px;
}
.navbar-brand .logo, .navbar-brand .logo-alt {
max-height: 50px;
display: block;
}
#nav:not(.nav-transparent):not(.fixed-nav) .navbar-brand .logo-alt {
display: none;
}
#nav.nav-transparent:not(.fixed-nav) .navbar-brand .logo {
display: none;
}
#nav.fixed-nav .navbar-brand .logo-alt {
display: none;
}
#media only screen and (max-width: 767px) {
#nav.nav-transparent .navbar-brand .logo-alt {
display: none !important;
}
#nav.nav-transparent .navbar-brand .logo {
display: block !important;
}
}
/*------------------------------------*\
Navigation
\*------------------------------------*/
#nav {
padding: 10px 0px;
background: #FFF;
-webkit-transition: 0.2s padding;
transition: 0.2s padding;
z-index: 999;
}
#nav.navbar {
border: none;
border-radius: 0;
margin-bottom: 0px;
}
#nav.fixed-nav {
position: fixed;
left: 0;
right: 0;
padding: 0px 0px;
background-color: #FFF !important;
border-bottom: 1px solid #EEE;
}
#nav.nav-transparent {
background: transparent;
}
/* -- default nav -- */
#media only screen and (min-width: 768px) {
.main-nav li {
padding: 0px 15px;
}
.main-nav li a {
font-size: 14px;
-webkit-transition: 0.2s color;
transition: 0.2s color;
}
.main-nav>li>a {
color: #10161A;
padding: 15px 0px;
}
#nav.nav-transparent:not(.fixed-nav) .main-nav>li>a {
color: #000;
}
.main-nav>li>a:hover, .main-nav>li>a:focus, .main-nav>li.active>a {
background: transparent;
color: #6195FF;
}
.main-nav>li>a:after {
content: "";
display: block;
background-color: #6195FF;
height: 2px;
width: 0%;
-webkit-transition: 0.2s width;
transition: 0.2s width;
}
.main-nav>li>a:hover:after, .main-nav>li.active>a:after {
width: 100%;
}
/* dropdown */
.has-dropdown {
position: relative;
}
.has-dropdown>a:before {
font-family: 'FontAwesome';
content: "\f054";
font-size: 6px;
margin-left: 6px;
float: right;
-webkit-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
-webkit-transition: 0.2s transform;
transition: 0.2s transform;
}
.dropdown {
position: absolute;
right: -50%;
top: 0;
background-color: #6195FF;
width: 200px;
-webkit-box-shadow: 0px 5px 5px -5px rgba(53, 64, 82, 0.2);
box-shadow: 0px 5px 5px -5px rgba(53, 64, 82, 0.2);
-webkit-transform: translateY(15px) translateX(50%);
-ms-transform: translateY(15px) translateX(50%);
transform: translateY(15px) translateX(50%);
opacity: 0;
visibility: hidden;
-webkit-transition: 0.2s all;
transition: 0.2s all;
}
.main-nav>.has-dropdown>.dropdown {
top: 100%;
right: 50%;
}
.main-nav>.has-dropdown>.dropdown .dropdown.dropdown-left {
right: 150%;
}
.dropdown li a {
display: block;
color: #FFF;
border-top: 1px solid rgba(250, 250, 250, 0.1);
padding: 10px 0px;
}
.dropdown li:nth-child(1) a {
border-top: none;
}
.has-dropdown:hover>.dropdown {
opacity: 1;
visibility: visible;
-webkit-transform: translateY(0px) translateX(50%);
-ms-transform: translateY(0px) translateX(50%);
transform: translateY(0px) translateX(50%);
}
.has-dropdown:hover>a:before {
-webkit-transform: rotate(0deg);
-ms-transform: rotate(0deg);
transform: rotate(0deg);
}
.nav-collapse {
display: none;
}
}
/* -- mobile nav -- */
#media only screen and (max-width: 767px) {
#nav {
padding: 0px 0px;
}
#nav.nav-transparent {
background: #FFF;
}
.main-nav {
position: fixed;
right: 0;
height: calc(100vh - 80px);
-webkit-box-shadow: 0px 80px 0px 0px #1C1D21;
box-shadow: 0px 80px 0px 0px #1C1D21;
max-width: 250px;
width: 0%;
-webkit-transform: translateX(100%);
-ms-transform: translateX(100%);
transform: translateX(100%);
margin: 0;
overflow-y: auto;
background: #1C1D21;
-webkit-transition: 0.2s all;
transition: 0.2s all;
}
#nav.open .main-nav {
-webkit-transform: translateX(0%);
-ms-transform: translateX(0%);
transform: translateX(0%);
width: 100%;
}
.main-nav li {
border-top: 1px solid rgba(250, 250, 250, 0.1);
}
.main-nav li a {
display: block;
color: #FFF;
-webkit-transition: 0.2s all;
transition: 0.2s all;
}
.main-nav>li.active {
border-left: 6px solid #6195FF;
}
.main-nav li a:hover, .main-nav li a:focus {
background-color: #6195FF;
color: #FFF;
opacity: 1;
}
.has-dropdown>a:after {
content: "\f054";
font-family: 'FontAwesome';
float: right;
-webkit-transition: 0.2s -webkit-transform;
transition: 0.2s -webkit-transform;
transition: 0.2s transform;
transition: 0.2s transform, 0.2s -webkit-transform;
}
.dropdown {
opacity: 0;
visibility: hidden;
height: 0;
background: rgba(250, 250, 250, 0.1);
}
.dropdown li a {
padding: 6px 10px;
}
.has-dropdown.open-drop>a:after {
-webkit-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
}
.has-dropdown.open-drop>.dropdown {
opacity: 1;
visibility: visible;
height: auto;
-webkit-transition: 0.2s all;
transition: 0.2s all;
}
}
/* -- nav btn collapse -- */
.nav-collapse {
position: relative;
float: right;
width: 40px;
height: 40px;
margin-top: 5px;
margin-right: 5px;
cursor: pointer;
z-index: 99999;
}
.nav-collapse span {
display: block;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
position: absolute;
top: 50%;
left: 50%;
width: 25px;
}
.nav-collapse span:before, .nav-collapse span:after {
content: "";
display: block;
}
.nav-collapse span, .nav-collapse span:before, .nav-collapse span:after {
height: 4px;
background: #10161A;
-webkit-transition: 0.2s all;
transition: 0.2s all;
}
.nav-collapse span:before {
-webkit-transform: translate(0%, 10px);
-ms-transform: translate(0%, 10px);
transform: translate(0%, 10px);
}
.nav-collapse span:after {
-webkit-transform: translate(0%, -14px);
-ms-transform: translate(0%, -14px);
transform: translate(0%, -14px);
}
#nav.open .nav-collapse span {
background: transparent;
}
#nav.open .nav-collapse span:before {
-webkit-transform: translateY(0px) rotate(-135deg);
-ms-transform: translateY(0px) rotate(-135deg);
transform: translateY(0px) rotate(-135deg);
}
#nav.open .nav-collapse span:after {
-webkit-transform: translateY(-4px) rotate(135deg);
-ms-transform: translateY(-4px) rotate(135deg);
transform: translateY(-4px) rotate(135deg);
}
/*------------------------------------*\
Header
\*------------------------------------*/
header {
position: relative;
}
#home {
height: 100vh;
}
#home .home-wrapper {
position: absolute;
left: 0px;
right: 0px;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
text-align: center;
}
.home-content button {
margin-top: 20px;
}
.header-wrapper h2 {
display: inline-block;
margin-bottom: 0px;
}
.header-wrapper .breadcrumb {
float: right;
background: transparent;
margin-bottom: 0px;
}
.header-wrapper .breadcrumb .breadcrumb-item.active {
color: #868F9B;
}
.breadcrumb>li+li:before {
color: #868F9B;
}
/*------------------------------------*\
About
\*------------------------------------*/
.about {
position: relative;
text-align: center;
padding: 40px 20px;
border: 1px solid #EEE;
margin: 15px 0px;
}
.about i {
font-size: 36px;
color: #6195FF;
margin-bottom: 20px;
}
.about:after {
content: "";
background-color: #1C1D21;
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 0%;
z-index: -1;
-webkit-transition: 0.2s width;
transition: 0.2s width;
}
.about:hover:after {
width: 100%;
}
.about h3 {
-webkit-transition: 0.2s color;
transition: 0.2s color;
}
.about:hover h3 {
color: #fff;
}
/*------------------------------------*\
Portfolio
\*------------------------------------*/
.work {
position: relative;
padding: 20px;
}
.work>img {
width: 100%;
}
.work .overlay {
background: #1C1D21;
position: absolute;
top: 0px;
left: 0px;
right: 0px;
bottom: 0px;
opacity: 0;
-webkit-transition: 0.2s opacity;
transition: 0.2s opacity;
-webkit-transition-delay: 0.2s;
transition-delay: 0.2s;
}
.work:hover .overlay {
-webkit-transition-delay: 0s;
transition-delay: 0s;
opacity: 0.8;
}
.work .work-content {
position: absolute;
left: 25px;
right: 25px;
top: 50%;
text-align: center;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
.work .work-content h3 {
-webkit-transform: translateY(100%);
-ms-transform: translateY(100%);
transform: translateY(100%);
opacity: 0;
color: #FFF;
margin-bottom: 30px;
-webkit-transition: 0.2s all;
transition: 0.2s all;
-webkit-transition-delay: 0.1s;
transition-delay: 0.1s;
}
.work:hover .work-content h3 {
-webkit-transform: translateY(0%);
-ms-transform: translateY(0%);
transform: translateY(0%);
opacity: 1;
-webkit-transition-delay: 0.1s;
transition-delay: 0.1s;
}
.work .work-content span {
display: block;
text-transform: uppercase;
-webkit-transform: translateY(100%);
-ms-transform: translateY(100%);
transform: translateY(100%);
opacity: 0;
color: #6195FF;
margin-bottom: 5px;
-webkit-transition: 0.2s all;
transition: 0.2s all;
-webkit-transition-delay: 0.2s;
transition-delay: 0.2s;
}
.work:hover .work-content span {
-webkit-transform: translateY(0%);
-ms-transform: translateY(0%);
transform: translateY(0%);
opacity: 1;
-webkit-transition-delay: 0s;
transition-delay: 0s;
}
.work .work-link {
text-align: center;
margin-top: 20px;
opacity: 0;
-webkit-transition: 0.2s opacity;
transition: 0.2s opacity;
}
.work .work-link a {
display: inline-block;
width: 50px;
height: 50px;
background-color: #6195FF;
color: #FFF;
line-height: 50px;
text-align: center;
}
.work:hover .work-link {
-webkit-transition-delay: 0.2s;
transition-delay: 0.2s;
opacity: 1;
}
/*------------------------------------*\
Services
\*------------------------------------*/
.service {
position: relative;
padding: 40px 20px 40px 70px;
margin: 15px 0px;
border: 1px solid #EEE;
}
.service i {
position: absolute;
left: 20px;
text-align: center;
font-size: 32px;
color: #6195FF;
border-radius: 50%;
}
.service:after {
content: "";
background-color: #1C1D21;
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 0%;
z-index: -1;
-webkit-transition: 0.2s width;
transition: 0.2s width;
}
.service:hover:after {
width: 100%;
}
.service h3 {
-webkit-transition: 0.2s color;
transition: 0.2s color;
}
.service:hover h3 {
color: #fff;
}
/*------------------------------------*\
Why choose us
\*------------------------------------*/
.feature {
margin: 15px 0px;
}
.feature i {
float: left;
padding: 5px;
border-radius: 50%;
color: #6195FF;
border: 1px solid #6195FF;
margin-right: 5px;
}
/*------------------------------------*\
Numbers
\*------------------------------------*/
.number {
text-align: center;
margin: 15px 0px;
}
.number i {
color: #6195FF;
font-size: 36px;
margin-bottom: 20px;
}
.number h3 {
font-size: 36px;
margin-bottom: 30px;
}
/*------------------------------------*\
Pricing
\*------------------------------------*/
.pricing {
position: relative;
text-align: center;
border: 1px solid #EEE;
background-color: #FFF;
z-index: 11;
margin: 15px 0px;
}
.pricing::after {
content: "";
background-color: #1C1D21;
position: absolute;
left: 0;
right: 0;
top: 0;
height: 0%;
z-index: -1;
-webkit-transition: 0.2s height;
transition: 0.2s height;
}
.pricing:hover:after {
height: 100%;
}
.pricing .price-head {
position: relative;
margin-bottom: 20px;
}
.pricing .price-title {
display: block;
padding: 40px 0px 20px;
text-transform: uppercase;
-webkit-transition: 0.2s color;
transition: 0.2s color;
}
.pricing:hover .price-title {
color: #6195FF;
}
.pricing .price {
position: relative;
width: 140px;
height: 140px;
line-height: 140px;
text-align: center;
margin: auto;
border-radius: 50%;
border: 2px solid #6195FF;
}
.pricing .price h3 {
font-size: 42px;
margin: 0px;
-webkit-transition: 0.2s color;
transition: 0.2s color;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
top: 50%;
position: absolute;
left: 0;
right: 0;
}
.pricing:hover .price h3 {
color: #fff;
}
.pricing .duration {
display: block;
font-size: 14px;
text-transform: uppercase;
color: #10161A;
-webkit-transition: 0.2s color;
transition: 0.2s color;
}
.pricing:hover .duration {
color: #fff;
}
.pricing .price-btn {
padding-top: 20px;
padding-bottom: 40px;
}
/*------------------------------------*\
Testimonial
\*------------------------------------*/
.testimonial {
margin: 15px 0px;
}
.testimonial-meta {
position: relative;
padding-left: 90px;
height: 70px;
margin-bottom: 20px;
padding-top: 10px;
}
.testimonial img {
position: absolute;
left: 0;
top: 0;
width: 70px !important;
height: 70px !important;
border-radius: 50%;
}
.testimonial h3 {
margin-bottom: 5px;
}
.testimonial span {
font-size: 14px;
color: #6195FF;
text-transform: uppercase;
}
/*------------------------------------*\
Team
\*------------------------------------*/
.team {
position: relative;
background-color: #F4F4F4;
padding: 40px 20px;
margin: 15px 0px;
}
.team::after {
content: "";
background-color: #1C1D21;
position: absolute;
left: 0;
right: 0;
top: 0;
height: 0%;
z-index: 1;
-webkit-transition: 0.2s height;
transition: 0.2s height;
}
.team:hover:after {
height: 100%;
}
.team-img {
position: relative;
margin-bottom: 20px;
z-index: 11;
}
.team-img>img {
width: 100%;
}
.team .overlay {
background: #1C1D21;
position: absolute;
bottom: 0;
left: 0;
right: 0;
top: 0;
opacity: 0;
-webkit-transition: 0.2s opacity;
transition: 0.2s opacity;
}
.team:hover .overlay {
opacity: 0.8;
}
.team .team-content {
text-align: center;
position: relative;
z-index: 11;
}
.team .team-content h3 {
margin-bottom: 30px;
-webkit-transition: 0.2s color;
transition: 0.2s color;
}
.team .team-content span {
font-size: 14px;
text-transform: uppercase;
-webkit-transition: 0.2s color;
transition: 0.2s color;
}
.team:hover .team-content h3 {
color: #FFF;
}
.team:hover .team-content span {
color: #6195FF;
}
.team .team-social {
position: absolute;
top: 0;
right: 0;
opacity: 0;
-webkit-transition: 0.2s opacity;
transition: 0.2s opacity;
}
.team .team-social a {
display: block;
line-height: 50px;
width: 50px;
text-align: center;
background-color: #6195FF;
color: #FFF;
}
.team:hover .team-social {
opacity: 1;
}
.rainbow {
/* Font options */
font-size:40px;
/* Chrome, Safari, Opera */
-webkit-animation: rainbow 3s infinite;
/* Internet Explorer */
-ms-animation: rainbow 3s infinite;
/* Standar Syntax */
animation: rainbow 3s infinite;
}
/* Chrome, Safari, Opera */
#-webkit-keyframes rainbow{
0%{color: orange;}
10%{color: purple;}
20%{color: red;}
30%{color: CadetBlue;}
40%{color: yellow;}
50%{color: coral;}
60%{color: green;}
70%{color: cyan;}
80%{color: DeepPink;}
90%{color: DodgerBlue;}
100%{color: orange;}
}
/* Internet Explorer */
#-ms-keyframes rainbow{
0%{color: orange;}
10%{color: purple;}
20%{color: red;}
40%{color: yellow;}
60%{color: green;}
100%{color: orange;}
}
/* Standar Syntax */
#keyframes rainbow{
0%{color: orange;}
10%{color: purple;}
20%{color: red;}
40%{color: yellow;}
60%{color: green;}
100%{color: orange;}
}
/* blog reply form */
.reply-form {
margin: 40px 0px;
}
.reply-form form .input, .reply-form form .input , .reply-form form textarea {
margin-bottom:20px;
}
.reply-form form .input, .reply-form form .input {
width: calc(50% - 10px);
display: inline-block;
}
.reply-form form .input:nth-child(2) {
margin-left: 15px;
}
/*------------------------------------*\
Blog sidebar
\*------------------------------------*/
#aside .widget {
margin-bottom: 40px;
}
.widget h3 {
text-transform: uppercase;
}
/* -- search sidebar -- */
#aside .widget-search {
position: relative;
}
#aside .widget-search .search-input {
padding-right: 50px;
}
#aside .widget-search .search-btn {
position: absolute;
right: 0px;
bottom: 0px;
width: 40px;
height: 40px;
border: none;
line-height: 40px;
background-color: transparent;
color: #6195FF;
}
/* -- category sidebar -- */
.widget-category a {
display: block;
font-size: 14px;
color: #354052;
border-bottom: 1px solid #EEE;
padding: 5px;
}
.widget-category a:nth-child(1) {
border-top: 1px solid #EEE;
}
.widget-category a span {
float: right;
color: #6195FF;
}
.widget-category a:hover {
color: #6195FF;
}
/* -- tags sidebar -- */
.widget-tags a {
display: inline-block;
padding: 6px 13px;
font-size: 14px;
margin: 2px 0px;
background: #F4F4F4;
color: #10161A;
}
.widget-tags a:hover {
color: #FFF;
background-color: #6195FF;
}
/* -- posts sidebar -- */
.widget-post {
min-height: 70px;
margin-bottom: 25px;
}
.widget-post img {
display: block;
float: left;
margin-right: 10px;
margin-top: 5px;
}
.widget-post a {
display: block;
color: #10161A;
}
.widget-post a:hover {
color: #6195FF;
}
.widget-post .blog-meta {
display: inline-block;
}
.widget-post .blog-meta li {
display: inline-block;
margin-right: 5px;
color: #6195FF;
font-size: 12px;
}
.widget-post li i {
color: #6195FF;
margin-right: 5px;
}
/*------------------------------------*\
Contact
\*------------------------------------*/
.contact {
margin: 15px 0px;
text-align: center;
}
.contact i {
font-size: 36px;
color: #6195FF;
margin-bottom: 20px;
}
.contact-form {
text-align: center;
margin-top: 40px;
}
.contact-form .input {
margin-bottom: 20px;
}
.contact-form .input:nth-child(1), .contact-form .input:nth-child(2) {
width: calc(50% - 10px);
}
.contact-form .input:nth-child(2) {
margin-left: 15px;
}
/*------------------------------------*\
Footer
\*------------------------------------*/
#footer {
position: relative;
}
.footer-logo {
text-align: center;
margin-bottom: 40px;
}
.footer-logo>a>img {
max-height: 80px;
}
.footer-follow {
text-align: center;
margin-bottom: 20px;
}
.footer-follow li {
display: inline-block;
margin-right: 10px;
margin-bottom: 13px;
}
.footer-follow li a {
display: inline-block;
width: 50px;
height: 50px;
line-height: 50px;
text-align: center;
border-radius: 3px;
background-color: #6195FF;
color:#FFF;
}
.footer-copyright p {
text-align: center;
font-size: 200px;
text-transform: uppercase;
margin: 0;
height: 20px;
}
}
.home-content__main {
padding-top: 24rem;
position: relative;
}
/*------------------------------------*\
Responsive
\*------------------------------------*/
#media only screen and (max-width: 991px) {}
#media only screen and (max-width: 767px) {
.section-header h2.title {
font-size:31.5px;
}
.main-btn , .default-btn , .outline-btn , .white-btn {
padding: 8px 22px;
font-size:14px;
}
.home-content h1 {
font-size:36px;
}
.header-wrapper h2 {
margin-bottom: 20px;
text-align: center;
display: block;
}
.header-wrapper .breadcrumb {
float: none;
text-align: center;
}
}
#media only screen and (max-width: 480px) {
#portfolio [class*='col-xs'] {
width:100%;
}
#numbers [class*='col-xs'] {
width:100%;
}
.contact-form .input:nth-child(1), .contact-form .input:nth-child(2) {
width: 100%;
}
.contact-form .input:nth-child(2) {
margin-left: 0px;
}
.reply-form form .input, .reply-form form .input {
width: 100%;
}
.reply-form form .input:nth-child(2) {
margin-left: 0px;
}
.blog-author .media .media-left {
display: block;
padding-right: 0;
margin-bottom: 20px;
}
.blog-author .media {
text-align: center;
}
.blog-author .media .media-heading .author-social {
margin-top: 10px;
float: none;
}
.blog-author .media .media-left img {
margin: auto;
}
.blog-comments .media .media {
margin:0px -15px;
}
}
/*------------------------------------*\
Owl theme
\*------------------------------------*/
/* -- dots -- */
.owl-theme .owl-dots .owl-dot span {
border: none;
background: #EEE;
-webkit-transition: 0.2s all;
transition: 0.2s all;
}
.owl-theme .owl-dots .owl-dot:hover span {
background: #6195FF;
}
.owl-theme .owl-dots .owl-dot.active span {
background: #6195FF;
width:20px;
}
.row {
width: 94%;
max-width: 1200px;
margin: 0 auto;
}
.row:after {
content: "";
display: table;
clear: both;
}
.row .row {
width: auto;
max-width: none;
margin-left: -20px;
margin-right: -20px;
}
/* -- nav -- */
.owl-theme .owl-nav {
opacity: 0;
-webkit-transition: 0.2s opacity;
transition: 0.2s opacity;
}
.owl-theme:hover .owl-nav {
opacity: 1;
}
.owl-theme .owl-nav [class*='owl-'] {
position: absolute;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
background: #6195FF;
color: #FFF;
padding: 0px;
width: 50px;
height: 50px;
border-radius:3px;
line-height: 50px;
margin: 0;
}
.owl-theme .owl-prev {
left: 0px;
}
.owl-theme .owl-next {
right: 0px;
}
.owl-theme .owl-nav [class*='owl-']:hover {
opacity: 0.8;
background: #6195FF;
}
/*------------------------------------*\
Back to top
\*------------------------------------*/
#back-to-top {
display:none;
position: fixed;
bottom: 20px;
right: 20px;
width: 50px;
height: 50px;
line-height: 50px;
text-align: center;
background: #6195FF;
border-radius:3px;
color: #FFF;
z-index: 9999;
-webkit-transition: 0.2s opacity;
transition: 0.2s opacity;
cursor: pointer;
}
#back-to-top:after {
content: "\f106";
font-family: 'FontAwesome';
}
#back-to-top:hover {
opacity: 0.8;
}
/*------------------------------------*\
Preloader
\*------------------------------------*/
#preloader {
position: fixed;
left: 0;
top: 0;
bottom: 0;
right: 0;
background-color: #FFF;
z-index: 99999;
}
.preloader {
position: absolute;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.preloader span {
display: inline-block;
background-color: #6195FF;
width: 25px;
height: 25px;
-webkit-animation: 1s preload ease-in-out infinite;
animation: preload 1s ease-in-out infinite;
-webkit-transform: scale(0);
-ms-transform: scale(0);
transform: scale(0);
border-radius:50%;
}
.preloader span:nth-child(1) {
-webkit-animation-delay: 0s;
animation-delay: 0s;
}
.preloader span:nth-child(2) {
-webkit-animation-delay: 0.1s;
animation-delay: 0.1s;
}
.preloader span:nth-child(3) {
-webkit-animation-delay: 0.15s;
animation-delay: 0.15s;
}
.preloader span:nth-child(4) {
-webkit-animation-delay: 0.2s;
animation-delay: 0.2s;
}
#-webkit-keyframes preload {
0% {
-webkit-transform:scale(0);
transform:scale(0);
}
50% {
-webkit-transform:scale(1);
transform:scale(1);
}
100% {
-webkit-transform:scale(0);
transform:scale(0);
}
}
#keyframes preload {
0% {
-webkit-transform:scale(0);
transform:scale(0);
}
50% {
-webkit-transform:scale(1);
transform:scale(1);
}
100% {
-webkit-transform:scale(0);
transform:scale(0);
}
}
I tried a few things but none worked, because I'm an nob.

Transform transition not working on responsive nav menu

I have a nav menu I made and I can't get the transform transition to work when I close the menu it only works when I open it. Here is my html
header#main {
position: fixed;
width: 100%;
z-index: 10;
box-shadow: 4px 1px 5px 1px rgba(0,0,0,0.75);
}
.container {
width: 95%;
margin: 0 auto;
}
header {
background: #FFFFFF;
padding: 1em 0 !important;
position: relative;
}
header::after {
content: '';
clear: both;
display: block;
}
.logo-container {
float: left;
margin-left:1em;
}
.site-nav {
position: absolute;
top: 2.3em;
right: 0;
}
.site-nav--open {
}
.site-nav ul {
padding: 0;
list-style: none;
}
.site-nav li {
border-bottom: none;
display:inline-block;
margin-left:3em;
}
.site-nav li:last-child {
border-bottom: none;
}
.site-nav a {
font-family:abel;
color: #333;
letter-spacing:2px;
padding:1.3em;
text-transform: uppercase;
text-decoration: none;
text-align:center;
}
a.login-nav {
color: white;
background: #ef7899;
padding-top: 2.4em !important;
padding-bottom: 2.25em !important;
padding-left: 2em !important;
padding-right: 2em!important ;
transition:background 0.5s ease-in-out;
}
a.login-nav:hover {
background:#000 !important;
color:white !important;
}
.site-nav a:hover,
.site-nav a:focus {
color: #333;
}
.site-nav--icon {
display: inline-block;
font-size: 1.5em;
margin-right: 1em;
width: 1.1em;
text-align: right;
color: rgba(255,255,255,.4);
}
.menu-toggle {
padding: 1em;
position: absolute;
top: 1.8em;
right: .7em;
cursor: pointer;
z-index:101;
display:none;
}
.hamburger,
.hamburger::before,
.hamburger::after {
content: '';
display: block;
background: #555;
height: 3px;
width: 1.75em;
border-radius: 3px;
transition: all ease-in-out 500ms;
}
.hamburger::before {
transform: translateY(-6px);
}
.hamburger::after {
transform: translateY(3px);
}
.open .hamburger {
transform: rotate(45deg);
background:black;
}
.open .hamburger::before {
opacity: 0;
}
.open .hamburger::after {
transform: translateY(-3px) rotate(-90deg);
background:black;
}
#media screen and (max-width: 1000px) {
.logo-container img {
width: 200px;
}
.menu-toggle {
display:block;
}
.site-nav {
position: absolute;
top: 100%;
right: 0%;
transform: translateX(100%);
transition:transform 0.8s ease;
}
.site-nav a{
display:none;
}
.site-nav li{
display:block;
}
.site-nav--open {
display: flex;
position: fixed;
top: 0;
right: 0;
z-index: 100;
transform: translateX(70%);
background: white;
height: 100%;
width: 100%;
transition:transform 0.8s ease;
}
.site-nav--open ul{
align-self:center;
}
.site-nav--open a {
font-family:abel;
color: #000;
display: inline-block;
letter-spacing:2px;
padding:1.3em;
text-transform: uppercase;
text-decoration: none;
text-align:center;
}
}
<header id="main">
<div class="container">
<div class="logo-container">
<h1>test</h1>
</div>
<nav class="site-nav">
<ul class="navi">
<li><span class="liner"><a class="vert" href="#one">Invest</a></span></li>
<li><span class="liner"><a class="vert" href="#two">Subscribe</a></span></li>
<li><span class="liner"><a class="vert" href="#why">Why Us</a></span></li>
<li><span class="liner"><a class="vert" href="#three">Faq</a></span></li>
<li class="log"><a class="login-nav" href="http://www.google.com"><i class="fa fa-sign-in" aria-hidden="true"></i>Login</a></li>
</ul>
</nav>
<div class="menu-toggle">
<div class="hamburger"></div>
</div>
</div>
</header>
I also have some jquery code, but all that does is toggle the menu and add a class when it's open so not sure if it's important to post it or not but here it is.
$('.menu-toggle').click(function() {
$('.site-nav').toggleClass('site-nav--open');
$(this).toggleClass('open');
$('.landing').toggleClass('landing-open');
})
Just replace css in .site-nav--open to .site-nav
$('.menu-toggle').click(function() {
$('.site-nav').toggleClass('site-nav--open');
$(this).toggleClass('open');
$('.landing').toggleClass('landing-open');
})
header#main {
position: fixed;
width: 100%;
z-index: 10;
box-shadow: 4px 1px 5px 1px rgba(0,0,0,0.75);
}
.container {
width: 95%;
margin: 0 auto;
}
header {
background: #FFFFFF;
padding: 1em 0 !important;
position: relative;
}
header::after {
content: '';
clear: both;
display: block;
}
.logo-container {
float: left;
margin-left:1em;
}
.site-nav {
position: absolute;
top: 2.3em;
right: 0;
}
.site-nav ul {
padding: 0;
list-style: none;
}
.site-nav li {
border-bottom: none;
display:inline-block;
margin-left:3em;
}
.site-nav li:last-child {
border-bottom: none;
}
.site-nav a {
font-family:abel;
color: #333;
letter-spacing:2px;
padding:1.3em;
text-transform: uppercase;
text-decoration: none;
text-align:center;
}
a.login-nav {
color: white;
background: #ef7899;
padding-top: 2.4em !important;
padding-bottom: 2.25em !important;
padding-left: 2em !important;
padding-right: 2em!important ;
transition:background 0.5s ease-in-out;
}
a.login-nav:hover {
background:#000 !important;
color:white !important;
}
.site-nav a:hover,
.site-nav a:focus {
color: #333;
}
.site-nav--icon {
display: inline-block;
font-size: 1.5em;
margin-right: 1em;
width: 1.1em;
text-align: right;
color: rgba(255,255,255,.4);
}
.menu-toggle {
padding: 1em;
position: absolute;
top: 1.8em;
right: .7em;
cursor: pointer;
z-index:101;
display:none;
}
.hamburger,
.hamburger::before,
.hamburger::after {
content: '';
display: block;
background: #555;
height: 3px;
width: 1.75em;
border-radius: 3px;
transition: all ease-in-out 500ms;
}
.hamburger::before {
transform: translateY(-6px);
}
.hamburger::after {
transform: translateY(3px);
}
.open .hamburger {
transform: rotate(45deg);
background:black;
}
.open .hamburger::before {
opacity: 0;
}
.open .hamburger::after {
transform: translateY(-3px) rotate(-90deg);
background:black;
}
#media screen and (max-width: 1000px) {
.logo-container img {
width: 200px;
}
.menu-toggle {
display:block;
}
.site-nav {
position: fixed;
top: 0%;
right: 0%;
transform: translateX(100%);
transition:transform 0.8s ease;
background: white;
height: 100%;
width: 310px;
z-index: 100;
}
.site-nav a{
display:none;
}
.site-nav li{
display:block;
}
.site-nav--open {
transform: translateX(0%);
}
.site-nav--open ul{
align-self:center;
}
.site-nav--open a {
font-family:abel;
color: #000;
display: inline-block;
letter-spacing:2px;
padding:1.3em;
text-transform: uppercase;
text-decoration: none;
text-align:center;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<header id="main">
<div class="container">
<div class="logo-container">
<h1>test</h1>
</div>
<nav class="site-nav">
<ul class="navi">
<li><span class="liner"><a class="vert" href="#one">Invest</a></span></li>
<li><span class="liner"><a class="vert" href="#two">Subscribe</a></span></li>
<li><span class="liner"><a class="vert" href="#why">Why Us</a></span></li>
<li><span class="liner"><a class="vert" href="#three">Faq</a></span></li>
<li class="log"><a class="login-nav" href="http://www.google.com"><i class="fa fa-sign-in" aria-hidden="true"></i>Login</a></li>
</ul>
</nav>
<div class="menu-toggle">
<div class="hamburger"></div>
</div>
</div>
</header>
Working Demo

Creating a CSS hover style that doesn't jump

I made a mobile responsive hamburger menu to horizontal nav bar, but I'm having trouble making a hover style for the links on the horizontal nav bar that don't make them jump. If you look at my Codpen you'll see the general style I want on those links on hover, but I want that highlight to be larger around the wording. When I've tried to do this the links end up jumping on hover. The other thing is that I can't get the top highlight much bigger... it's like it's cut off with some other property. This is the first menu like this I've made (I'm fairly new) so I played around with a lot of different CSS properties and values to get things to look perfect upon first glance and I'm sure some CSS isn't right, I just don't know what or where. I pasted the code below with everything inline but definitely check out the codpen because that's more accurate to how it looks on my computer. Thanks for your help!
http://codepen.io/sshine2/pen/VbjGaE
EDIT: I edited the code in Codepen to show how the top of the highlight gets cut off and the link jumps when the highlight is the size I want it to be.
SECOND EDIT: Fixed the top being cut off myself. Changed where the entire menu was displayed.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
body {
font-family: 'Noto Sans', sans-serif;
margin: 0;
width: 100%;
height: 100vh;
background: #ffffff;
background-color: black;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
header {
width: 100%;
background: #ffffff;
position: fixed;
height: 4em;
line-height: 4em;
display: inline-block;
padding-left: 1em;
border-bottom: .1em solid #dddddd;
}
h2 {
font-size: 2.1em;
}
p {
font-size: 10em;
color: white;
padding-top: 1em;
}
#media only screen and (min-width: 319px) {
.menu {
z-index: 1;
display: none;
font-weight: bold;
font-size: 1.2em;
width: 100%;
background: #f1f1f1;
position: fixed;
text-align: center;
margin-top: 3.3em;
color: black;
}
.menu ul {
margin: 0;
padding: 0;
list-style-type: none;
list-style-image: none;
border-top: #dddddd 1px solid;
}
.menu li {
display: block;
padding: 1em 0 1em 0;
border-bottom: #dddddd 1px solid;
}
.menu li:hover {
display: block;
background: #585858;
padding: 1em 0 1em 0;
cursor: crosshair;
}
.menu ul li a {
text-decoration: none;
margin: 0px;
color: black;
}
.menu ul li a:hover {
color: white;
text-decoration: none;
}
.menu a {
text-decoration: none;
color: black;
}
.menu a:hover {
text-decoration: none;
color: white;
}
#nav-icon4 {
width: 35px;
height: 25px;
float: right;
margin-top: -47px;
margin-right: 30px;
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
-webkit-transition: .5s ease-in-out;
-moz-transition: .5s ease-in-out;
-o-transition: .5s ease-in-out;
transition: .5s ease-in-out;
cursor: cell;
}
#nav-icon4 span {
display: block;
position: absolute;
height: 5px;
width: 100%;
background: darkred;
border-radius: 7px;
opacity: 2;
left: 0;
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
-webkit-transition: .25s ease-in-out;
-moz-transition: .25s ease-in-out;
-o-transition: .25s ease-in-out;
transition: .25s ease-in-out;
}
#nav-icon4 span:nth-child(1) {
top: 0px;
-webkit-transform-origin: left center;
-moz-transform-origin: left center;
-o-transform-origin: left center;
transform-origin: left center;
}
#nav-icon4 span:nth-child(2) {
top: 10px;
-webkit-transform-origin: left center;
-moz-transform-origin: left center;
-o-transform-origin: left center;
transform-origin: left center;
}
#nav-icon4 span:nth-child(3) {
top: 20px;
-webkit-transform-origin: left center;
-moz-transform-origin: left center;
-o-transform-origin: left center;
transform-origin: left center;
}
#nav-icon4.open span:nth-child(1) {
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
top: 0;
left: 6px;
}
#nav-icon4.open span:nth-child(2) {
width: 0%;
opacity: 0;
}
#nav-icon4.open span:nth-child(3) {
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
top: 25px;
left: 6px;
}
}
#media only screen and (min-width : 768px) {
h2 {
z-index: 1000000;
font-size: 1.5em;
}
p {
font-size: 20em;
color: white;
padding-top: 1em;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
}
li {
float: right;
margin-left: 20px;
margin-right: 8px;
margin-top: -10px;
}
li a {
display: block;
text-align: center;
text-decoration: none;
}
.menu {
display: block!important;
position: absolute;
right: 0px;
font-size: .9em;
width: 100%;
padding-right: 15px;
margin-top: 10px;
padding-top: 10px;
padding-bottom: 10px;
background: rgba(255, 255, 255, 0);
}
.menu ul {
border-bottom: 0;
border-top: 0;
}
.menu li {
border-bottom: 0;
border-top: 0;
}
.menu li:hover {
cursor: crosshair;
padding-top: 1em;
padding-bottom: .4em;
padding-right: 0em;
padding-left: 0em;
}
.menu ul li a:hover {
color: white;
}
#nav-icon4 {
display: none;
}
}
#media only screen and (min-width : 922px) {
li {
margin-left: 55px;
margin-right: 18px;
}
.menu {
padding-right: 1px;
}
}
#media only screen and (min-width : 1400px) {
header {
height: 5em;
line-height: 5em;
}
h2 {
font-size: 2.6em;
}
li {
margin-left: 55px;
margin-right: 30px;
}
.menu {
padding-right: 1px;
font-size: 1.2em;
}
}
</style>
<title>hamburgers</title>
</head>
<body>
<header>
<span>Shine Design</span>
<div id="nav-icon4">
<span></span>
<span></span>
<span></span>
</div>
</header>
<div class="menu">
<ul>
<a href="#">
<li>LINK ONE</li>
</a>
<a href="#">
<li>LINK TWO</li>
</a>
<a href="#">
<li>LINK THREE</li>
</a>
<a href="#">
<li>LINK FOUR</li>
</a>
<a href="#">
<li>LINK FIVE</li>
</a>
</ul>
</div>
</body>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">google.load("jquery", "1.3.2");</script>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
$(document).ready(function(){
$('#nav-icon4').click(function(){
$(this).toggleClass('open');
});
});
</script>
</html>
The jumping issue is because you add padding on hover which isn't there before.
Before your media queries define the padding ones:
.menu li {
border-bottom: 0;
border-top: 0;
padding: 1em;
}
Then remove the defined paddings for .menu li in your min 768px query.,
code pen