I'm trying to make a header for a project. There will be dropdown menus. But there is a problem with mobile compatibility as below.
It looks like this when working beautifully above 991 pixels and below 991 pixels and this is very annoying. Can you help?
$('.main-d-l').hover(
function(){ $('.arrow').addClass('fa-rotate-270') },
function(){ $('.arrow').removeClass('fa-rotate-270') }
)
$(document).ready(function(){
// Toggle Navigation Bar
$('.hamburger-menu').click(function(){
$('.nav-btn').toggleClass("active");
$('.hamburger-menu').toggleClass("active");
});
// Toggle Dropdown Menu
$('.main-dropdown-link').click(function(){
$('.dropdown').toggleClass("active");
});
});
header {
position: fixed;
top: 0;
background-color: #fff;
width: 100%;
z-index: 1000;
box-shadow: 0 0px 10px 5px rgba(0, 0, 0, .05);
}
header .container {
width: 100%;
max-width: 120rem;
height: 7rem;
margin: 0px auto;
display: flex;
position: relative;
}
header .container .logo-container {
display: flex;
align-items: center;
}
header .container .logo-container img {
height: 7rem;
}
header .container .logo-container h1 {
font-family: 'Arima Madurai', cursive;
font-weight: 900;
margin-bottom: 0px;
font-size: 2rem;
}
header .container .logo-container h1 a {
text-decoration: none;
color: #503775;
}
header .container .nav-btn {
flex: 3;
display: flex;
}
header .container .nav-btn .nav-links {
flex: 2;
}
header .container .nav-btn .nav-links>ul {
display: flex;
justify-content: flex-end;
align-items: center;
}
header .container .nav-btn .nav-links ul .nav-link {
position: relative;
cursor: pointer;
height: 7rem;
display: flex;
align-items: center;
justify-content: center;
padding: 0px 20px;
transition: .3s;
}
header .container .nav-btn .nav-links ul .nav-link:hover {
background-color: #95389E;
}
header .container .nav-btn .nav-links ul .nav-link>a {
position: relative;
width: 100%;
font-size: 1.5rem;
height: 7rem;
color: #95389E;
font-weight: 600;
text-decoration: none;
display: flex;
align-items: center;
justify-content: space-between;
transition: .3s;
}
header .container .nav-btn .nav-links ul .nav-link:hover>a {
color: #fff;
}
header .container .nav-btn .nav-links ul .nav-link>a i {
margin-right: 5px;
}
header .container .nav-btn .search-box {
display: flex;
align-items: center;
justify-content: center;
margin-left: 10px;
}
header .container .nav-btn .search-box form {
display: flex;
align-items: center;
justify-content: center;
border-left: 2px solid #e0e0e0;
height: 7rem;
}
header .container .nav-btn .search-box form input {
font-size: 1.2rem;
padding: 8px;
border: none;
outline: 0;
width: 15rem;
}
header .container .nav-btn .search-box form button {
height: 7rem;
padding: 0px 1rem;
border: none;
background-color: #fff;
font-size: 1.8rem;
color: #5A5A5A;
transition: .3s;
}
header .container .nav-btn .search-box form button:hover {
color: #95389E;
}
header .container .nav-btn .nav-links ul .nav-link .main-dropdown-link .arrow {
margin-left: 5px;
transition: .3s;
}
header .container .nav-btn .nav-links ul .nav-link .dropdown {
position: absolute;
top: 70px;
left: 0;
width: 30rem;
border-radius: 0px 0px 5px 5px;
background-color: #fff;
border-top: 2px solid #95389E;
border-left: 1px solid #e0e0e0;
border-right: 1px solid #e0e0e0;
border-bottom: 1px solid #e0e0e0;
transform: translateY(0px);
opacity: 0;
pointer-events: none;
transition: .5s;
}
header .container .nav-btn .nav-links ul .nav-link .dropdown ul {
list-style: none;
position: relative;
padding: 10px 5px;
}
header .container .nav-btn .nav-links ul .nav-link .dropdown ul .dropdown-link>a {
display: flex;
color: #95389E;
font-size: 1.4rem;
font-weight: 600;
text-decoration: none;
padding: .6rem 1rem;
align-items: center;
justify-content: space-between;
transition: .3s;
}
header .container .nav-btn .nav-links ul .nav-link .dropdown ul .dropdown-link>a:hover {
padding-left: 2rem;
}
header .container .nav-btn .nav-links ul .nav-link:hover>.dropdown {
transform: translate(0, 0);
opacity: 1;
pointer-events: auto;
}
header .container .hamburger-menu-container {
flex: 1;
display: none;
align-items: center;
justify-content: flex-end
}
header .container .hamburger-menu-container .hamburger-menu {
width: 5rem;
height: 5rem;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
}
header .container .hamburger-menu-container .hamburger-menu div {
width: 3.6rem;
height: 4px;
border-radius: 1px;
background-color: #95389E;
position: relative;
z-index: 1001;
transition: .5s;
}
header .container .hamburger-menu-container .hamburger-menu div::after,
header .container .hamburger-menu-container .hamburger-menu div::before {
content: '';
position: absolute;
width: inherit;
height: inherit;
background-color: #95389E;
border-radius: 1px;
transition: .5s;
}
header .container .hamburger-menu-container .hamburger-menu div::before {
transform: translateY(-12px);
}
header .container .hamburger-menu-container .hamburger-menu div::after {
transform: translateY(12px);
}
header .container .hamburger-menu-container .hamburger-menu.active div {
background-color: transparent;
}
header .container .hamburger-menu-container .hamburger-menu.active div::before {
transform: translateY(0) rotate(-45deg);
}
header .container .hamburger-menu-container .hamburger-menu.active div::after {
transform: translateY(0) rotate(45deg);
}
#keyframes headerAnimation {
from {
opacity: 0;
transform: translateY(15px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
#media (max-width: 991px) {
header .container .hamburger-menu-container {
display: flex
}
header .container #check {
display: block
}
header .container .nav-btn {
position: fixed;
height: calc(100vh - 7rem);
top: 7rem;
right: -100%;
width: 100%;
background-color: #fff;
flex-direction: column;
align-items: center;
justify-content: space-between;
overflow-x: hidden;
overflow-y: auto;
transition: .6s
}
header .container .nav-btn .nav-links {
flex: initial;
width: 100%
}
header .container .nav-btn .nav-links>ul {
justify-content: center;
flex-direction: column
}
header .container .nav-btn .nav-links ul .nav-link {
width: 100%;
transition: .3s;
opacity: 0;
transform: translateY(15px)
}
header .container .nav-btn .nav-links ul .nav-link>a {
line-height: 1;
padding: 1.6rem 2rem
}
header .container .nav-btn .nav-links ul .nav-link>a i {
display: none;
}
header .container .nav-btn .nav-links ul .nav-link>a i.arrow {
display: block;
}
header .container .nav-btn .nav-links ul .nav-link>a:hover {
padding-left: 30px
}
header .container .nav-btn .nav-links ul .nav-link>a::before {
display: none
}
header .container .nav-btn .nav-links ul .nav-link .dropdown {
position: initial;
top: initial;
left: initial;
transform: initial;
opacity: 1;
pointer-events: auto;
width: 100%;
padding: 0;
display: none;
}
header .container .nav-btn .nav-links ul .nav-link>.dropdown.active {
display: block;
}
header .container .nav-btn.active {
right: 0
}
.nav-btn.active ul .nav-link {
animation: headerAnimation .3s ease forwards .6s
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<!-- Custom Style -->
<link rel="stylesheet" href="css/style.css">
<!-- Library -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<!-- FontAwesome -->
<script src="https://kit.fontawesome.com/cd25521a32.js" async crossorigin="anonymous"></script>
</head>
<body>
<!-- Header -->
<header>
<div class="container">
<div class="logo-container">
<a href="index.html" title="RaBlogin">
<img src="img/RaBlogin.png" alt="RaBlogin">
</a>
<h1>RaBlogin</h1>
</div>
<nav class="nav-btn">
<div class="nav-links">
<ul>
<li class="nav-link">
<i class="fas fa-home"></i> Anasayfa
</li>
<li class="nav-link main-d-l">
<a class="main-dropdown-link"><i class="fas fa-th-list"></i> Kategoriler <i class="fas fa-chevron-down arrow"></i></a>
<div class="dropdown">
<ul>
<li class="dropdown-link">
Blog
</li>
<li class="dropdown-link">
SEO
</li>
<li class="dropdown-link">
WordPress
</li>
<li class="dropdown-link">
Web Yazılımları
</li>
<li class="dropdown-link">
Genel Yazılar
</li>
</ul>
</div>
</li>
<li class="nav-link">
<i class="fas fa-bookmark"></i> Hakkımızda
</li>
<li class="nav-link">
<i class="far fa-comment"></i> İletişim
</li>
</ul>
</div>
<div class="search-box">
<form action="">
<input type="text" placeholder="Arama Yap...">
<button type="submit" class="search-icon"><i class="fas fa-search"></i></button>
</form>
</div>
</nav>
<div class="hamburger-menu-container">
<div class="hamburger-menu">
<div></div>
</div>
</div>
</div>
</header>
<!-- Header End -->
<!-- Scripts -->
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script src="js/script.js"></script>
</body>
</html>
How can I solve this problem? In the mobile version, the dropdown part does not push other elements and stays on the side.
Related
I am currently building out my portfolio, and while working on the sidebar and testing for mobile responsivness, i ran into a small problem.
i have a div that acts as my sidebar, it has a position fixed, with a top and left 0. and in desktop view, it stays on scroll and works as i would expect. however through the inspect tab, and mobile view, the sidebar scrolls with the page. Code is attached below, in a perfect world i would be able to keep the sidebar where it is supposed to be in the mobile view. and this is specific to the mobile view, if you just shrink the main window to the media query width, it works as expected. Thanks!!
EDIT:
What iwant it to look like: https://youtu.be/w3AT3WHHL4o
what it looks like: https://youtu.be/kbfS8vBKAlU
<div class="side-nav">
<a href="#home" class="logo">
<img class="logo-img" src="Images/Logo.png">
<img class="icon-img" src="Images/Icon.png">
</a>
<ul class="nav-links">
<li><i class="fa-solid fa-user scrollLink"></i><p>About</p></li>
<li><i class="fa-solid fa-folder scrollLink"></i><p>Projects</p></li>
<li><i class="fa-solid fa-file scrollLink"></i><p>Resume</p></li>
<div class="active"></div>
</ul>
</div>
<style>
.side-nav {
width: 250px;
height: 100vh;
background: #9E9E9E;
position: fixed;
top: 0;
left: 0;
padding: 20px 30px;
}
.logo {
display: block;
margin-bottom: 130px;
}
.logo-img {
display: block;
width: 190px;
}
.icon-img {
display: none;
}
.nav-links {
list-style: none;
position: relative;
}
.nav-links li {
padding: 10px 0;
}
.nav-links li a {
color: white;
text-decoration: none;
padding: 10px 14px;
display: flex;
align-items: center;
}
.nav-links li a i {
font-size: 22px;
margin-right: 20px;
}
.active {
background: white;
width: 100%;
height: 47px;
position: absolute;
left: 0;
top: 4%;
z-index: -1;
border-radius: 6px;
box-shadow: 0 5px 10px rgba(255, 255, 255, 0.4);
display: none;
transition: top 0.5s;
}
.nav-links li:hover a {
color: #9E9E9E;
transition: 0.3s;
}
.nav-links li:hover ~ .active {
display: block;
}
.nav-links li:nth-child(1):hover ~ .active{
top: 4%;
}
.nav-links li:nth-child(2):hover ~ .active{
top: 35.9%;
}
.nav-links li:nth-child(3):hover ~ .active{
top: 69.2%;
}
#media only screen and (max-width: 600px){
.side-nav {
width: 110px;
}
.nav-links li a p {
display: none;
}
.nav-links li a i {
margin-right: 0;
}
.nav-links li a {
justify-content: center;
}
.logo-img {
display: none;
}
.icon-img {
display: block;
}
}
</style>
i have commented the things i added. i am sorry i would not be able to explain because you setup is very messy & need to refactored.
.side-nav {
width: 250px;
height: 100vh;
background: #9E9E9E;
position: fixed;
top: 0;
left: 0;
padding: 20px 30px;
}
.logo {
display: block;
margin-bottom: 130px;
}
.logo-img {
display: block;
width: 190px;
}
.icon-img {
display: none;
}
.nav-links {
list-style: none;
position: relative;
}
.nav-links li {
padding: 10px 0;
}
.nav-links li a {
color: white;
text-decoration: none;
padding: 10px 14px;
display: flex;
align-items: center;
}
.nav-links li a i {
font-size: 22px;
margin-right: 20px;
}
.active {
background: white;
width: 100%;
height: 47px;
position: absolute;
left: 0;
top: 4%;
z-index: -1;
border-radius: 6px;
box-shadow: 0 5px 10px rgba(255, 255, 255, 0.4);
display: none;
transition: top 0.5s;
}
.nav-links li:hover a {
color: #9E9E9E;
transition: 0.3s;
}
.nav-links li:hover~.active {
display: block;
}
.nav-links li:nth-child(1):hover~.active {
top: 4%;
}
.nav-links li:nth-child(2):hover~.active {
top: 35.9%;
}
.nav-links li:nth-child(3):hover~.active {
top: 69.2%;
}
#media only screen and (max-width: 600px) {
.side-nav {
width: 100px;
height: 70vh;
padding: 2px 3px; /*i added*/
display: flex; /*i added*/
flex-direction: column; /*i added*/
align-items: space-between; /*i added*/
}
.nav-links li a i {
font-size: 12px; /*i added*/
margin-right: 0px; /*i added*/
}
.logo {
display: block;
margin-bottom: 30px; /*i added*/
}
.nav-links li a p {
display: none;
}
.nav-links li a i {
margin-right: 0;
}
.nav-links li a {
justify-content: flex-start; /*i added*/
}
.logo-img {
display: none;
}
.icon-img {
display: block;
}
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css" rel="stylesheet" />
<div class="side-nav">
<a href="#home" class="logo">
<img class="logo-img" src="Images/Logo.png">
<img class="icon-img" src="Images/Icon.png">
</a>
<ul class="nav-links">
<li><i class="fa-solid fa-user scrollLink"></i><p>About</p></li>
<li><i class="fa-solid fa-folder scrollLink"></i><p>Projects</p></li>
<li><i class="fa-solid fa-file scrollLink"></i><p>Resume</p></li>
<div class="active"></div>
</ul>
</div>
I would like the title to be at the bottom of the header, here is an example below
Except that, my problem is that the title is placed at the same height as the header and not at the bottom.
If I remove the header block, you can see the title.
I think it's a problem with my blocks? However, there is one solution, but I want to avoid doing a padding-top on the title to get this result:
I made a reproduction angular.
Here is a reproduction html/css.
#import url('https://fonts.googleapis.com/css2?family=Poppins:wght#200;300;400;500;600;700&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
list-style: none;
text-decoration: none;
}
.sidebar {
position: fixed;
height: 100%;
width: 240px;
background: #0a2558;
transition: all 0.5s ease;
}
.sidebar.active {
width: 60px;
}
.sidebar .logo-details {
height: 100px;
display: flex;
align-items: center;
background-color: #fff;
}
.sidebar .logo-details i {
font-size: 28px;
font-weight: 500;
color: #fff;
min-width: 60px;
text-align: center;
}
.sidebar .logo-details .logo_name img {
height: 100px;
margin-left: 18px;
}
.sidebar .nav-links {
margin-top: 10px;
}
.sidebar .nav-links li {
position: relative;
list-style: none;
}
.sidebar .nav-links li a {
display: flex;
justify-content: start;
text-decoration: none;
transition: all 0.4s ease;
border-bottom: 1px solid #ccc;
padding: 13px 0;
}
.sidebar .nav-links li a.active {
background: #081d45;
}
.sidebar .nav-links li a:hover {
background: #081d45;
}
.sidebar .nav-links li i {
min-width: 60px;
text-align: center;
font-size: 18px;
color: #fff;
}
.sidebar .nav-links .item {
text-transform: uppercase;
}
.sidebar .nav-links li i.fa-chevron-down {
right: 0;
position: absolute;
}
.sidebar .nav-links li.active i.fa-chevron-down {
transform: rotate(180deg);
}
.sidebar .nav-links li.active i {
color: white;
}
.sidebar .nav-links li a .links_name {
color: #fff;
font-size: 15px;
font-weight: 400;
white-space: nowrap;
}
.home-section {
position: relative;
background: #f5f5f5;
min-height: 100vh;
width: calc(100% - 240px);
left: 240px;
transition: all 0.5s ease;
}
.home-section .heading {
display: flex;
justify-content: space-between;
height: 100px;
background: #fff;
align-items: center;
position: fixed;
width: calc(100% - 240px);
left: 240px;
z-index: 100;
padding: 0 20px;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
transition: all 0.5s ease;
}
.home-section .heading .sidebar-button {
display: flex;
align-items: center;
font-size: 24px;
font-weight: 500;
}
.heading .sidebar-button i {
font-size: 35px;
margin-right: 10px;
}
.menu-summary-container {
display: grid;
margin: 0 auto;
text-align: center;
width: 100%;
}
.menu-summary-container .user,
.menu-summary-container .last-connection {
font-size: 22px;
}
<head>
<meta charset="utf-8">
<title>Titre de la page</title>
<link rel="stylesheet" href="style.css">
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<link href="https://unpkg.com/boxicons#2.0.7/css/boxicons.min.css" rel="stylesheet" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" />
<script src="script.js"></script>
</head>
<body>
<div class="sidebar">
<div class="logo-details">
<span class="logo_name">
<a href="https://zupimages.net/viewer.php?id=22/30/27uw.png"
><img src="https://zupimages.net/up/22/30/27uw.png" alt=""
/></a>
</span>
</div>
<ul class="nav-links">
<li>
<a href="#">
<span class="links_name" style="margin-left: 20px;">Administrateur</span>
<i class="fa fa-chevron-down"></i>
</a>
</li>
</ul>
</div>
<section class="home-section">
<div class="heading">
<div class="sidebar-button">
<i class="bx bx-menu sidebarBtn"></i>
</div>
<div class="menu-summary-container">
<span class="user">User: </span>
<span class="last-connection">last connection: </span>
</div>
</div>
<h1>Portfolio page</h1>
</section>
</body>
Thank you a lot for your help.
If you must use a fixed position together with flexbox you can wrap the text in another div:
<div class="heading text">
<h1>Portfolio page</h1>
</div>
I then added some additional CSS:
.home-section .heading.text {
height: calc(100% - 100px);
align-items: start;
top: 100px;
padding-top: 10px;
background: #eee;
}
If you can follow the advice from #isherwood and don't mix fixed position and flexbox at all.
Example layouts using flexbox can be searched on the internet.
#import url('https://fonts.googleapis.com/css2?family=Poppins:wght#200;300;400;500;600;700&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
list-style: none;
text-decoration: none;
}
.sidebar {
position: fixed;
height: 100%;
width: 240px;
background: #0a2558;
transition: all 0.5s ease;
}
.sidebar.active {
width: 60px;
}
.sidebar .logo-details {
height: 100px;
display: flex;
align-items: center;
background-color: #fff;
}
.sidebar .logo-details i {
font-size: 28px;
font-weight: 500;
color: #fff;
min-width: 60px;
text-align: center;
}
.sidebar .logo-details .logo_name img {
height: 100px;
margin-left: 18px;
}
.sidebar .nav-links {
margin-top: 10px;
}
.sidebar .nav-links li {
position: relative;
list-style: none;
}
.sidebar .nav-links li a {
display: flex;
justify-content: start;
text-decoration: none;
transition: all 0.4s ease;
border-bottom: 1px solid #ccc;
padding: 13px 0;
}
.sidebar .nav-links li a.active {
background: #081d45;
}
.sidebar .nav-links li a:hover {
background: #081d45;
}
.sidebar .nav-links li i {
min-width: 60px;
text-align: center;
font-size: 18px;
color: #fff;
}
.sidebar .nav-links .item {
text-transform: uppercase;
}
.sidebar .nav-links li i.fa-chevron-down {
right: 0;
position: absolute;
}
.sidebar .nav-links li.active i.fa-chevron-down {
transform: rotate(180deg);
}
.sidebar .nav-links li.active i {
color: white;
}
.sidebar .nav-links li a .links_name {
color: #fff;
font-size: 15px;
font-weight: 400;
white-space: nowrap;
}
.home-section {
position: relative;
background: #f5f5f5;
min-height: 100vh;
width: calc(100% - 240px);
left: 240px;
transition: all 0.5s ease;
}
.home-section .heading {
display: flex;
justify-content: space-between;
height: 100px;
background: #fff;
align-items: center;
position: fixed;
width: calc(100% - 240px);
left: 240px;
z-index: 100;
padding: 0 20px;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
transition: all 0.5s ease;
}
.home-section .heading.text {
height: calc(100% - 100px);
align-items: start;
top: 100px;
padding-top: 10px;
background: #eee;
}
.home-section .heading .sidebar-button {
display: flex;
align-items: center;
font-size: 24px;
font-weight: 500;
}
.heading .sidebar-button i {
font-size: 35px;
margin-right: 10px;
}
.menu-summary-container {
display: grid;
margin: 0 auto;
text-align: center;
width: 100%;
}
.menu-summary-container .user,
.menu-summary-container .last-connection {
font-size: 22px;
}
<head>
<meta charset="utf-8">
<title>Titre de la page</title>
<link rel="stylesheet" href="style.css">
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<link href="https://unpkg.com/boxicons#2.0.7/css/boxicons.min.css" rel="stylesheet" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" />
<script src="script.js"></script>
</head>
<body>
<div class="sidebar">
<div class="logo-details">
<span class="logo_name">
<a href="https://zupimages.net/viewer.php?id=22/30/27uw.png"
><img src="https://zupimages.net/up/22/30/27uw.png" alt=""
/></a>
</span>
</div>
<ul class="nav-links">
<li>
<a href="#">
<span class="links_name" style="margin-left: 20px;">Administrateur</span>
<i class="fa fa-chevron-down"></i>
</a>
</li>
</ul>
</div>
<section class="home-section">
<div class="heading">
<div class="sidebar-button">
<i class="bx bx-menu sidebarBtn"></i>
</div>
<div class="menu-summary-container">
<span class="user">User: </span>
<span class="last-connection">last connection: </span>
</div>
</div>
<div class="heading text">
<h1>Portfolio page</h1>
</div>
</section>
</body>
I'm trying to add a header on top of this image with a gradient that I've made but it gives me a weird white background as such https://i.stack.imgur.com/ppuJq.png I want the text on top of the image to have a transparent background. Made the navbar black so its easier to see but anyway, how do I remove it? I am aware that the js script is unfinished if that has anything to do with it.
here is my code
/*
CSS for the page:
*/
* {
margin: 0;
}
.WelcomeMenu h1 {
font-size: 50px;
}
.WelcomeMenu img {
width: 100%;
height: 85vh;
}
.img-gradient {
position: absolute;
width: 100%;
height: 85vh;
}
.img-gradient::after {
content: '';
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 85vh;
background: linear-gradient(rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.85));
}
.MiddleMenu {
color: #FFFF;
height: 600vh;
}
/*
CSS for navbar:
*/
body {
font-family: 'Noto Sans', sans-serif;
}
img {
width: 600px;
margin-left: 0;
margin-top: 0;
margin-bottom: 50px;
}
nav {
align-items: center;
padding: 20px;
display: flex;
justify-content: space-between;
background-color: #000;
transition-duration: 0.3s;
transition-timing-function: linear;
transition-delay: 0.1s;
}
nav .fa {
display: none;
}
nav:hover {
opacity: 100;
}
.nav-list .active {
color: #F10000;
opacity: 1;
}
.nav-list img {
width: 110px;
margin-left: -40px;
margin-top: -30px;
margin-bottom: -35px;
}
.nav-list {
text-align: right;
}
.nav-list ul li {
list-style: none;
display: inline-block;
padding: 2px 20px;
position: relative;
}
.nav-list ul li a {
text-decoration: none;
color: #F10000;
font-size: 20px;
opacity: 1;
}
.nav-list ul li::after {
content: '';
width: 0%;
height: 4px;
background: #C5C6C7;
display: block;
margin: auto;
transition: 0.6s;
}
.nav-list ul li:hover::after {
width: 100%;
}
#media (max-width: 700px) {
.nav-list ul li {
display: block;
}
.nav-list {
position: absolute;
background: black;
height: 125vh;
width: 175px;
top: 0;
right: -300px;
text-align: left;
z-index: 2;
transition: 1s;
}
.nav-list ul li a {
font-size: 15px;
}
.nav-list ul li {
padding: 20px;
}
nav .fa {
display: block;
color: white;
margin: 10px;
font-size: 20px;
cursor: pointer;
padding-left: 10px;
padding-top: 5px;
}
}
<!-- Bootstrap-4 -->
<title> Lookout </title>
<link rel="preconnect" href="https://fonts.googleapis.com/%22%3E">
<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght#0,400;0,700;1,400;1,700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- Body -->
<section class="header">
<nav>
<div class="nav-list" id="navList">
<i class="fa fa-times" onclick="hideMenu()"></i>
<ul>
<li> AAAA </li>
<li> AAAA </li>
<li> AAAA </li>
<li> AAAA </li>
<li> AAAAAA </li>
<img src="Bilder/Medietilsynet.png">
</ul>
</div>
<i class="fa fa-bars" onclick="showMenu()"></i>
</nav>
</section>
<section>
<div class="WelcomeMenu">
<h1> STOP THINK & CHECK. </H1>
<div class="img-gradient">
<img src="https://sites.google.com/site/quackquackquest/_/rsrc/1469302829712/duck-duck-maps/duck%20banner%203.jpg">
</div>
</div>
</section>
<section>
<div class="MiddleMenu">
</div>
</section>
It's because of the background color on body tag and the transparent background on .WelcomeMenu. Ways to fix (Only one of them):
Add a background color to .WelcomeMenu
Have a parent element and set the background color to black
Make the background color of body black
/*
CSS for the page:
*/
* {
margin: 0;
}
.WelcomeMenu {
background-color: red
}
.WelcomeMenu h1 {
font-size: 50px;
}
.WelcomeMenu img {
width: 100%;
height: 85vh;
}
.img-gradient {
position: absolute;
width: 100%;
height: 85vh;
}
.img-gradient::after {
content: '';
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 85vh;
background: linear-gradient(rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.85));
}
.MiddleMenu {
color: #FFFF;
height: 600vh;
}
/*
CSS for navbar:
*/
body {
font-family: 'Noto Sans', sans-serif;
}
img {
width: 600px;
margin-left: 0;
margin-top: 0;
margin-bottom: 50px;
}
nav {
align-items: center;
padding: 20px;
display: flex;
justify-content: space-between;
background-color: #000;
transition-duration: 0.3s;
transition-timing-function: linear;
transition-delay: 0.1s;
}
nav .fa {
display: none;
}
nav:hover {
opacity: 100;
}
.nav-list .active {
color: #F10000;
opacity: 1;
}
.nav-list img {
width: 110px;
margin-left: -40px;
margin-top: -30px;
margin-bottom: -35px;
}
.nav-list {
text-align: right;
}
.nav-list ul li {
list-style: none;
display: inline-block;
padding: 2px 20px;
position: relative;
}
.nav-list ul li a {
text-decoration: none;
color: #F10000;
font-size: 20px;
opacity: 1;
}
.nav-list ul li::after {
content: '';
width: 0%;
height: 4px;
background: #C5C6C7;
display: block;
margin: auto;
transition: 0.6s;
}
.nav-list ul li:hover::after {
width: 100%;
}
#media (max-width: 700px) {
.nav-list ul li {
display: block;
}
.nav-list {
position: absolute;
background: black;
height: 125vh;
width: 175px;
top: 0;
right: -300px;
text-align: left;
z-index: 2;
transition: 1s;
}
.nav-list ul li a {
font-size: 15px;
}
.nav-list ul li {
padding: 20px;
}
nav .fa {
display: block;
color: white;
margin: 10px;
font-size: 20px;
cursor: pointer;
padding-left: 10px;
padding-top: 5px;
}
}
<!-- Bootstrap-4 -->
<title> Lookout </title>
<link rel="preconnect" href="https://fonts.googleapis.com/%22%3E">
<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght#0,400;0,700;1,400;1,700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- Body -->
<section class="header">
<nav>
<div class="nav-list" id="navList">
<i class="fa fa-times" onclick="hideMenu()"></i>
<ul>
<li> AAAA </li>
<li> AAAA </li>
<li> AAAA </li>
<li> AAAA </li>
<li> AAAAAA </li>
<img src="Bilder/Medietilsynet.png">
</ul>
</div>
<i class="fa fa-bars" onclick="showMenu()"></i>
</nav>
</section>
<section>
<div class="WelcomeMenu">
<h1> STOP THINK & CHECK. </H1>
<div class="img-gradient">
<img src="https://sites.google.com/site/quackquackquest/_/rsrc/1469302829712/duck-duck-maps/duck%20banner%203.jpg">
</div>
</div>
</section>
<section>
<div class="MiddleMenu">
</div>
</section>
The image that you are using is a background image! so for a better solution you can make it the background of the div.WelcomeMenu.
The white color is the background of the page (by default - which is blank white page). and the order of the elements is:
Navbar - black background
h1 - the background of the page
img - the image itself
that means, the h1 is between the two elements.
In case you still want the elements as they are, you can simply add:
.WelcomeMenu {
position: relative;
}
.WelcomeMenu h1 {
color: #ffffff;
font-size: 50px;
position: absolute;
top: 100px; (change it as you wish)
left: 100px; (change it as you wish)
}
The Code:
/*
CSS for the page:
*/
* {
margin: 0;
}
.WelcomeMenu {
position: relative;
height: 85vh;
width: 100%;
background-image: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)),
url("https://sites.google.com/site/quackquackquest/_/rsrc/1469302829712/duck-duck-maps/duck%20banner%203.jpg");
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.WelcomeMenu h1 {
color: #ffffff;
font-size: 50px;
}
.MiddleMenu {
color: #FFFF;
height: 600vh;
}
/*
CSS for navbar:
*/
body {
font-family: 'Noto Sans', sans-serif;
}
img {
width: 600px;
margin-left: 0;
margin-top: 0;
margin-bottom: 50px;
}
nav {
align-items: center;
padding: 20px;
display: flex;
justify-content: space-between;
background-color: #000;
transition-duration: 0.3s;
transition-timing-function: linear;
transition-delay: 0.1s;
}
nav .fa {
display: none;
}
nav:hover {
opacity: 100;
}
.nav-list .active {
color: #F10000;
opacity: 1;
}
.nav-list img {
width: 110px;
margin-left: -40px;
margin-top: -30px;
margin-bottom: -35px;
}
.nav-list {
text-align: right;
}
.nav-list ul li {
list-style: none;
display: inline-block;
padding: 2px 20px;
position: relative;
}
.nav-list ul li a {
text-decoration: none;
color: #F10000;
font-size: 20px;
opacity: 1;
}
.nav-list ul li::after {
content: '';
width: 0%;
height: 4px;
background: #C5C6C7;
display: block;
margin: auto;
transition: 0.6s;
}
.nav-list ul li:hover::after {
width: 100%;
}
#media (max-width: 700px) {
.nav-list ul li {
display: block;
}
.nav-list {
position: absolute;
background: black;
height: 125vh;
width: 175px;
top: 0;
right: -300px;
text-align: left;
z-index: 2;
transition: 1s;
}
.nav-list ul li a {
font-size: 15px;
}
.nav-list ul li {
padding: 20px;
}
nav .fa {
display: block;
color: white;
margin: 10px;
font-size: 20px;
cursor: pointer;
padding-left: 10px;
padding-top: 5px;
}
}
<!-- Bootstrap-4 -->
<title> Lookout </title>
<link rel="preconnect" href="https://fonts.googleapis.com/%22%3E">
<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght#0,400;0,700;1,400;1,700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- Body -->
<section class="header">
<nav>
<div class="nav-list" id="navList">
<i class="fa fa-times" onclick="hideMenu()"></i>
<ul>
<li> AAAA </li>
<li> AAAA </li>
<li> AAAA </li>
<li> AAAA </li>
<li> AAAAAA </li>
<img src="Bilder/Medietilsynet.png">
</ul>
</div>
<i class="fa fa-bars" onclick="showMenu()"></i>
</nav>
</section>
<section>
<div class="WelcomeMenu">
<h1> STOP THINK & CHECK. </h1>
</div>
</section>
/* GLOBAL */
#import url('https://fonts.googleapis.com/css2?family=Poppins:wght#200;400;600&display=swap');
:root {
--nav-hue: #2300d1;
--background-color: #100e1a;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: var(--background-color);
font-family: 'Poppins', sans-serif;
overflow-x: hidden;
}
h1, h2, h3, h4 {
font-weight: 300;
}
ul {
list-style: none;
}
a {
text-decoration: none;
color: white;
}
/* NAV */
.nav {
height: 60px;
width: 100vw;
background-color: black;
color: white;
border-bottom: 0.15rem solid var(--nav-hue);
}
.nav i {
margin-right: 0.3rem;
}
.logo {
display: inline;
padding: 0.1rem 1.5rem;
}
.nav .left-menu, .nav .right-menu {
display: flex;
align-items: center;
margin-top: 0.4rem;
}
.nav .left-menu {
flex: 2;
margin-left: 1rem;
}
.nav .right-menu {
flex: 1;
margin-left: 10rem;
}
.nav ul li {
padding: 0 0.8rem;
}
.nav-search {
border: 1px solid white;
padding: 0.4rem 0.6rem;
border-radius: 2px;
outline: none;
text-align: center;
}
.nav-search:focus {
transition: letter-spacing 200ms ease-in-out;
letter-spacing: 0.02rem;
border: 1px solid var(--nav-hue);
}
.nav .nav-hover:hover, .nav .nav-hover:hover a, .nav i:hover {
transition: all 100ms ease-in-out;
color: var(--nav-hue);
cursor: pointer;
}
.small-hover:hover {
transition: all 100ms ease-in-out;
transform: scale(1.5) translateY(-0.2rem);
}
/* MAIN */
.container {
max-width: 1100px;
margin: auto;
padding: 0.5rem;
}
/* SHOWCASE */
.showcase {
place-items: center;
margin-top: 1rem;
z-index: 2;
border: none;
}
.showcase-img {
width: 960px;
height: 470px;
border-radius: 2px;
border: 2px solid black;
box-shadow: 3px 3px 15px hsl(250, 100%, 41%);
}
.showcase-img img {
width: 100%;
height: 100%;
}
.showcase-img img:hover {
background-color: dodgerblue; /* testing */
transition: all 0.2s ease-in-out;
opacity: 0.7;
}
.showcase ul {
display: flex;
bottom: 15.6rem;
position: relative;
justify-content: space-between;
width: 85%;
}
.showcase ul li {
color: black;
font-size: 2.5rem;
}
.showcase ul li i:hover {
transition: all 150ms ease-in-out;
font-size: 2.7rem;
color: var(--nav-hue);
cursor: pointer;
}
.showcase ul li i:active {
transition: all 50ms ease-in-out;
transform: translateY(0.2rem);
font-size: 2.9rem;
color: white;
}
/* UTILS */
/* GRID & FLEX */
.flex {
display: flex;
text-align: center;
}
.column {
flex-direction: column;
}
.grid {
display: grid;
grid-template-columns: 1fr;
}
.grid-center {
place-items: center;
}
.nav-hue {
color: var(--nav-hue);
}
.bold {
font-weight: 400;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="all.css">
<title>GameBuy.com</title>
</head>
<body>
<!-- NAVBAR -->
<div class="nav">
<div class="flex">
<h1 class="logo">Game<span class="nav-hue bold">Buy.com</span></h1>
<ul class="left-menu">
<li><span class="nav-hover"><i class="fas fa-home"></i>Home</i></span></li>
<li><span class="nav-hover"><i class="fas fa-question"></i>About</i></span></li>
</ul>
<ul class="right-menu">
<li><input class="nav-search" type="search" placeholder="SEARCH"></li>
<li><i class="fas fa-shopping-cart small-hover"></i></li>
<li><i class="fas fa-search small-hover"></i></li>
</ul>
</div>
</div>
<div class="container">
<!-- SLIDER SHOWCASE -->
<div class="showcase grid">
<div class="showcase-img">
<img id="image" src="images/arma3.png" alt="">
</div>
<ul>
<li class="left-flash"><i id="left-flash" class="fas fa-chevron-left"></i></li>
<li class="right-flash"><i id="right-flash" class="fas fa-chevron-right"></i></li>
</ul>
</div>
</div>
<script src="index.js"></script>
</body>
</html>
// When i hover over the showcase-img container the opacity changes but when the mouse goes over the ul which contains 2 li's that are icons the hovering stops and the opacity resets which shouldn't happen, i want the opacity to stay at 0.7 while the mouse is in the showcase-img container, how can i fix this? Thanks!
Rather than applying :hover directly on image like this .showcase-img img:hover img{} apply it directly on parent div it means .showcase:hover img{}. This should be something like this:
/* GLOBAL */
#import url('https://fonts.googleapis.com/css2?family=Poppins:wght#200;400;600&display=swap');
:root {
--nav-hue: #2300d1;
--background-color: #100e1a;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: var(--background-color);
font-family: 'Poppins', sans-serif;
overflow-x: hidden;
}
h1, h2, h3, h4 {
font-weight: 300;
}
ul {
list-style: none;
}
a {
text-decoration: none;
color: white;
}
/* NAV */
.nav {
height: 60px;
width: 100vw;
background-color: black;
color: white;
border-bottom: 0.15rem solid var(--nav-hue);
}
.nav i {
margin-right: 0.3rem;
}
.logo {
display: inline;
padding: 0.1rem 1.5rem;
}
.nav .left-menu, .nav .right-menu {
display: flex;
align-items: center;
margin-top: 0.4rem;
}
.nav .left-menu {
flex: 2;
margin-left: 1rem;
}
.nav .right-menu {
flex: 1;
margin-left: 10rem;
}
.nav ul li {
padding: 0 0.8rem;
}
.nav-search {
border: 1px solid white;
padding: 0.4rem 0.6rem;
border-radius: 2px;
outline: none;
text-align: center;
}
.nav-search:focus {
transition: letter-spacing 200ms ease-in-out;
letter-spacing: 0.02rem;
border: 1px solid var(--nav-hue);
}
.nav .nav-hover:hover, .nav .nav-hover:hover a, .nav i:hover {
transition: all 100ms ease-in-out;
color: var(--nav-hue);
cursor: pointer;
}
.small-hover:hover {
transition: all 100ms ease-in-out;
transform: scale(1.5) translateY(-0.2rem);
}
/* MAIN */
.container {
max-width: 1100px;
margin: auto;
padding: 0.5rem;
}
/* SHOWCASE */
.showcase {
place-items: center;
margin-top: 1rem;
z-index: 2;
border: none;
}
.showcase-img {
width: 960px;
height: 470px;
border-radius: 2px;
border: 2px solid black;
box-shadow: 3px 3px 15px hsl(250, 100%, 41%);
}
.showcase-img img {
width: 100%;
height: 100%;
}
.showcase:hover img {
background-color: dodgerblue; /* testing */
transition: all 0.2s ease-in-out;
opacity: 0.7;
}
.showcase ul {
display: flex;
bottom: 15.6rem;
position: relative;
justify-content: space-between;
width: 85%;
}
.showcase ul li {
color: black;
font-size: 2.5rem;
}
.showcase ul li i:hover {
transition: all 150ms ease-in-out;
font-size: 2.7rem;
color: var(--nav-hue);
cursor: pointer;
}
.showcase ul li i:active {
transition: all 50ms ease-in-out;
transform: translateY(0.2rem);
font-size: 2.9rem;
color: white;
}
/* UTILS */
/* GRID & FLEX */
.flex {
display: flex;
text-align: center;
}
.column {
flex-direction: column;
}
.grid {
display: grid;
grid-template-columns: 1fr;
}
.grid-center {
place-items: center;
}
.nav-hue {
color: var(--nav-hue);
}
.bold {
font-weight: 400;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="all.css">
<title>GameBuy.com</title>
</head>
<body>
<!-- NAVBAR -->
<div class="nav">
<div class="flex">
<h1 class="logo">Game<span class="nav-hue bold">Buy.com</span></h1>
<ul class="left-menu">
<li><span class="nav-hover"><i class="fas fa-home"></i>Home</i></span></li>
<li><span class="nav-hover"><i class="fas fa-question"></i>About</i></span></li>
</ul>
<ul class="right-menu">
<li><input class="nav-search" type="search" placeholder="SEARCH"></li>
<li><i class="fas fa-shopping-cart small-hover"></i></li>
<li><i class="fas fa-search small-hover"></i></li>
</ul>
</div>
</div>
<div class="container">
<!-- SLIDER SHOWCASE -->
<div class="showcase grid">
<div class="showcase-img">
<img id="image" src="images/arma3.png" alt="">
</div>
<ul>
<li class="left-flash"><i id="left-flash" class="fas fa-chevron-left"></i></li>
<li class="right-flash"><i id="right-flash" class="fas fa-chevron-right"></i></li>
</ul>
</div>
</div>
<script src="index.js"></script>
</body>
</html>
HTMl SECTION
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css">
<link rel="stylesheet" href="style.css">
<title>Harm</title>
</head>
<body>
<!-- Desktop Nav -->
<header class="hero">
<div id="navbar" class="navbar">
<h1 class="logo">
<span class="text-primary"><i class="fas fa-book-open"></i>Edge</span> Ledger
</h1>
<nav>
<ul>
<li>Home</li>
<li>About</li>
<li>Cases</li>
<li>Blog</li>
<li>Contact</li>
</ul>
</nav>
</div>
<!-- Mobile Navigation-->
<div class="menu-wrap">
<input type="checkbox" class="toggler">
<div class="hamburger"><div></div></div>
<div class="menu">
<div>
<div>
<ul>
<li>Home</li>
<li>About</li>
<li>Services</li>
<li>Contact</li>
</ul>
</div>
</div>
</div>
</div>
<div class="content">
<h1>The Sky Is The limit</h1>
<p>We provide world class financial assistance</p>
<i class="fa fa-chevron-right" aria-hidden="true"></i>Read More
</div>
</header>
</body>
</html>
CSS SECTION
:root {
--primary-color: rgba(13, 110, 139, 0.75);
--secondary-color: rgba(229, 148, 0 , 0.9);
--overlay-color: rgba(24, 39, 51 , 0.85);
--menu-speed: 0.75s;
}
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
a{
text-decoration: none;
list-style: none;
}
ul{
list-style: none;
}
.navbar {
display: flex;
align-items: center;
justify-content: space-between;
background-color: #333;
color: #fff;
opacity: 0.8;
width: 100%;
height: 70px;
position: fixed;
top: 0px;
padding: 0 30px;
transition: 0.5s;
}
.navbar.top {
background: transparent;
}
.navbar a {
color: #fff;
padding: 10px 20px;
margin: 10px 5px;
list-style: none;
}
.navbar a:hover {
border-bottom: #28a745 2px solid;
}
.navbar ul {
display: flex;
}
.navbar .logo {
font-weight: 400;
}
/* Header */
.hero {
background: url('../images/home/showcase.jpg') no-repeat center center/cover;
height: 100vh;
position: relative;
color: #fff;
}
.hero .content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
height: 100%;
padding: 0 20px;
}
.hero .content h1 {
font-size: 55px;
}
.hero .content p {
font-size: 23px;
max-width: 600px;
margin: 20px 0 30px;
}
.hero::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.6);
}
.menu-wrap{
display: none;
}
#media (max-width:500px){
.navbar{
display: none;
}
.menu-wrap {
position: fixed;
top: 0;
left: 0;
z-index: 1;
}
.menu-wrap .toggler {
position: absolute;
top: 0;
left: 0;
z-index: 2;
cursor: pointer;
width: 50px;
height: 50px;
opacity: 0;
}
.menu-wrap .hamburger {
position: absolute;
top: 0;
left: 0;
z-index: 1;
width: 60px;
height: 60px;
padding: 1rem;
background: var(--primary-color);
display: flex;
align-items: center;
justify-content: center;
}
/* Hamburger Line */
.menu-wrap .hamburger > div {
position: relative;
flex: none;
width: 100%;
height: 2px;
background: #fff;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.4s ease;
}
/* Hamburger Lines - Top & Bottom */
.menu-wrap .hamburger > div::before,
.menu-wrap .hamburger > div::after {
content: '';
position: absolute;
z-index: 1;
top: -10px;
width: 100%;
height: 2px;
background: inherit;
}
/* Moves Line Down */
.menu-wrap .hamburger > div::after {
top: 10px;
}
/* Toggler Animation */
.menu-wrap .toggler:checked + .hamburger > div {
transform: rotate(135deg);
}
/* Turns Lines Into X */
.menu-wrap .toggler:checked + .hamburger > div:before,
.menu-wrap .toggler:checked + .hamburger > div:after {
top: 0;
transform: rotate(90deg);
}
/* Rotate On Hover When Checked */
.menu-wrap .toggler:checked:hover + .hamburger > div {
transform: rotate(225deg);
}
/* Show Menu */
.menu-wrap .toggler:checked ~ .menu {
visibility: visible;
}
.menu-wrap .toggler:checked ~ .menu > div {
transform: scale(1);
transition-duration: var(--menu-speed);
}
.menu-wrap .toggler:checked ~ .menu > div > div {
opacity: 1;
transition: opacity 0.4s ease 0.4s;
}
.menu-wrap .menu {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
visibility: hidden;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
}
.menu-wrap .menu > div {
background: var(--overlay-color);
border-radius: 50%;
width: 200vw;
height: 200vw;
display: flex;
flex: none;
align-items: center;
justify-content: center;
transform: scale(0);
transition: all 0.4s ease;
}
.menu-wrap .menu > div > div {
text-align: center;
max-width: 90vw;
max-height: 100vh;
opacity: 0;
transition: opacity 0.4s ease;
}
.menu-wrap .menu > div > div > ul > li {
list-style: none;
color: #fff;
font-size: 1.5rem;
padding: 1rem;
}
.menu-wrap .menu > div > div > ul > li > a {
color: inherit;
text-decoration: none;
transition: color 0.4s ease;
}
.menu-wrap .menu > div > div > ul > li > a:hover {
color: var(--secondary-color);
}
}
I am trying to remove the navigation bar by replacing it with the hamburger button when the screen width max is 500, the issue basically is when i am on large screens i want the navigation bar to display the normal way and when my screen width maximum is 500px, the navigation bar should change to a mobile navigation Menu
You should add "display: block" in the media query for .menu-wrap:
#media (max-width:500px){
.menu-wrap {
display: block;
}
}
You are missing out display:block
#media (max-width:500px){
.menu-wrap {
position: fixed;
top: 0;
left: 0;
z-index: 1;
display:block
}
}