I tried to create responsive menu which after resizing (<992px) create hamburger menu that will roll from the right side and it will be on 100vh of website's height. Everything works but the content of the website is on top of the sidebar menu after transition. I tried to set the position to absolute or relative nothing works. Also I tried to hide the content after label is checked but it didn't work too. Any ideas how can I fix that?
Code:
/* General */
html,
body {
height: 100%;
font-size: 100%;
font-family: 'Montserrat', sans-serif;
}
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
img {
max-width: 100%;
height: auto;
}
.wrapper {
min-height: 100%;
}
.container {
position: relative;
margin-right: auto;
margin-left: auto;
padding-left: 0.9375rem;
padding-right: 0.9375rem;
}
.main-content {
padding-top: 20px;
padding-bottom: 50px;
}
footer {
height: 50px;
margin-top: -50px;
background: linear-gradient(70deg, #0ebeff, #ffdd40, #ae63e4, #47cf73);
}
/* Menu */
.menu {
width: 100%;
height: 58px;
}
.menu-items ul {
float: right;
}
.menu-items ul li {
display: inline;
padding: 20px;
list-style: none;
}
.menu-items ul li a {
line-height: 75px;
font-weight: 300;
color: #000;
text-decoration: none;
}
.menu-items ul li a:hover {
color: #4956cc;
transition: 0.1s
}
.menu-items ul li a.active {
color: #ffa136;
}
.logo-place {
line-height: 75px;
display: inline;
float: left;
}
.checkbtn {
font-size: 30px;
color: #000;
float: right;
line-height: 85px;
cursor: pointer;
display: none;
}
#check {
display: none;
}
#media (max-width:992px) {
.checkbtn {
display: block;
}
.menu-items ul {
position: fixed;
width: 100%;
height: 100vh;
top: 80px;
right: -100%;
background: #000;
text-align: center;
transition: all .5s;
}
.menu-items ul li {
display: block;
margin-top: 10px;
}
.menu-items ul li a {
font-size: 20px;
color: #fff;
}
#check:checked~.menu-items ul {
right: 0;
}
}
/* Welcome-section */
.welcome-section {
background-color: red;
}
.welcome-section h1 {
color: #fff;
}
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght#300;500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css">
<div class="wrapper">
<div class="menu container">
<input type="checkbox" id="check">
<label for="check" class="checkbtn">
<i class="fas fa-bars"></i>
</label>
<div class="logo-place">
<img src="img/logo.png" alt="">
</div>
<div class="menu-items">
<ul>
<li><a class="active" href="index.html">My Story</a></li>
<li>Blog</li>
<li>Contact</li>
<li>Instagram</li>
<li>Linkedin</li>
</ul>
</div>
</div>
<div class="main-content">
<div class="welcome-section">
<div class="container">
<div class="portrait">
<img src="img/portrait.png" alt="">
</div>
<h1>bla bla bla bla bla <br> bla bla bla.</h1>
</div>
</div>
</div>
</div>
<footer></footer>
You need to give the sidebar a z-index:
.menu-items ul {
float: right;
z-index: 999; /* Insert this line */
}
The z-index CSS property sets the z-order of a positioned element and its descendants or flex items. Overlapping elements with a larger z-index cover those with a smaller one.
Source: MDN
/* General */
html,
body {
height: 100%;
font-size: 100%;
font-family: 'Montserrat', sans-serif;
}
html {
box-sizing: border-box;
}
*,
*::before,
*::after {
box-sizing: inherit;
}
img {
max-width: 100%;
height: auto;
}
.wrapper {
min-height: 100%;
}
.container {
position: relative;
margin-right: auto;
margin-left: auto;
padding-left: 0.9375rem;
padding-right: 0.9375rem;
}
.main-content {
padding-top: 20px;
padding-bottom: 50px;
}
footer {
height: 50px;
margin-top: -50px;
background: linear-gradient(70deg, #0ebeff, #ffdd40, #ae63e4, #47cf73);
}
/* Menu */
.menu {
width: 100%;
height: 58px;
}
.menu-items ul {
float: right;
z-index: 999;
}
.menu-items ul li {
display: inline;
padding: 20px;
list-style: none;
}
.menu-items ul li a {
line-height: 75px;
font-weight: 300;
color: #000;
text-decoration: none;
}
.menu-items ul li a:hover {
color: #4956cc;
transition: 0.1s
}
.menu-items ul li a.active {
color: #ffa136;
}
.logo-place {
line-height: 75px;
display: inline;
float: left;
}
.checkbtn {
font-size: 30px;
color: #000;
float: right;
line-height: 85px;
cursor: pointer;
display: none;
}
#check {
display: none;
}
#media (max-width:992px) {
.checkbtn {
display: block;
}
.menu-items ul {
position: fixed;
width: 100%;
height: 100vh;
top: 80px;
right: -100%;
background: #000;
text-align: center;
transition: all .5s;
}
.menu-items ul li {
display: block;
margin-top: 10px;
}
.menu-items ul li a {
font-size: 20px;
color: #fff;
}
#check:checked~.menu-items ul {
right: 0;
}
}
/* Welcome-section */
.welcome-section {
background-color: red;
}
.welcome-section h1 {
color: #fff;
}
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght#300;500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css">
<div class="wrapper">
<div class="menu container">
<input type="checkbox" id="check">
<label for="check" class="checkbtn">
<i class="fas fa-bars"></i>
</label>
<div class="logo-place">
<img src="img/logo.png" alt="">
</div>
<div class="menu-items">
<ul>
<li><a class="active" href="index.html">My Story</a></li>
<li>Blog</li>
<li>Contact</li>
<li>Instagram</li>
<li>Linkedin</li>
</ul>
</div>
</div>
<div class="main-content">
<div class="welcome-section">
<div class="container">
<div class="portrait">
<img src="img/portrait.png" alt="">
</div>
<h1>bla bla bla bla bla <br> bla bla bla.</h1>
</div>
</div>
</div>
</div>
<footer></footer>
Add z-index: 9; to .menu-items ul which is in #media (max-width:992px)
Related
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>
some device like iMac it look perfect but some i see white box in other pc.in tablet and mobile screen gets auto zoom its not fit to device i have to zoom out which makes content small.
* {
list-style: none;
text-decoration: none;
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: #f7f7f7;
color: #545454;
}
/* NAVIGATION */
.navbar {
width: 100%;
height: 150px;
background: black;
position: fixed;
top: 0;
left: 0;
padding: 0 25px;
}
.navbar .inner_navbar {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
height: 100%;
}
.navbar .hamburger {
display: none;
}
.navbar .menu ul {
display: flex;
}
.navbar .menu ul li a {
display: block;
width: 120px;
margin-right: 10px;
text-align: center;
font-size: 14px;
text-transform: uppercase;
color: #fff;
padding: 10px;
border-radius: 25px;
letter-spacing: 2px;
transition: all 0.2s ease;
}
.navbar .menu ul li:last-child a {
margin-right: 0;
}
.navbar .menu ul li a:hover,
.navbar .menu ul li a.active {
background: #5db485;
}
.container {
margin-top: 150px;
width: 1906px;
height: 397px;
}
.promo {
width: 1906px;
}
/* Safari Tours*/
.safari-tours {
background: linear-gradient(to bottom, #65214a, #8d2353, #b52455, #db2c4f, #fd3f41);
;
width: 1906px;
}
.safari-title {
text-align: center;
padding-top: 30px;
font-size: 50px;
}
.banner {
display: flex;
justify-content: center;
}
.safari {
margin: 2%;
}
.safari img {
width: 500px;
}
/*Tablet*/
#media (max-width: 992px) {
.navbar {
height: 218px;
padding: 12px;
}
.navbar .inner_navbar {
flex-direction: column;
}
.container {
margin-top: 218px;
}
}
/*Mobile*/
#media (max-width: 728px) {
.navbar {
height: 150px;
}
.navbar .inner_navbar {
flex-direction: row;
}
.navbar .menu ul {
position: absolute;
top: 150px;
left: 0;
display: block;
background: orangered;
width: 100%;
}
.navbar .menu ul li {
padding: 10px;
}
.navbar .menu ul li a {
width: 100%;
padding: 12px;
}
.navbar .hamburger {
display: block;
position: absolute;
top: 15px;
right: 25px;
color: #fff;
font-size: 24px;
cursor: pointer;
transition: all 0.2s ease;
}
.navbar .menu {
display: none;
}
.navbar .menu.activate {
display: block;
}
.container {
margin-top: 150px;
width: 690px;
height: 144px;
}
.promo {
width: 690px;
}
.safari-tours {
background: linear-gradient(to bottom, #65214a, #8d2353, #b52455, #db2c4f, #fd3f41);
width: 690px;
}
.safari {
margin: 1%;
}
.safari img {
width: 300px;
}
}
<!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>Home</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<div class="wrapper">
<div class="navbar">
<div class="inner_navbar">
<div class="logo">
<img src="/images/Final Logo.png" style="width: 150px;">
</div>
<div class="menu">
<ul>
<li>Home</li>
<li>Desert Safari</li>
<li>Tours</li>
<li>Activities</li>
<li>Contact-Us</li>
</ul>
</div>
</div>
<div class="hamburger">
<img src="/images/menu-btn.png" style="width: 40px;">
</div>
</div>
<div class="container">
<img class="promo" src="https://www.arabian-adventures.com/on/demandware.static/-/Sites-dnata-UAE-Library/default/dw922d22bf/images/slider/luxury-desert-camping-arabian-adventures-1920x400.jpg" alt="">
</div>
</div>
</header>
<section>
<div class="safari-tours">
<h1 class="safari-title">SAFARI TOURS</h1>
<div class="banner">
<div class="safari">
<img src="https://i.imgur.com/9QH8NFE.jpeg" alt="Morning Safari" />
</a>
</div>
<div class="safari">
<a href="https://bigdunestours.com/desert-safari" target="_top">
<img src="https://i.imgur.com/2E9ytwc.jpeg" alt="Evening Safari" />
</a>
</div>
</div>
</div>
</section>
<script>
var hamburger = document.querySelector(".hamburger");
var menu = document.querySelector(".menu");
hamburger.addEventListener("click", function() {
menu.classList.toggle("activate");
})
</script>
</body>
</html>
some device like iMac it look perfect but some i see white box in other pc.in tablet and mobile screen gets auto zoom its not fit to device i have to zoom out which makes content small.
edited i did try as one of the comment mention but still no luckk the results are something like this
*{
list-style: none;
text-decoration: none;
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{
background: #f7f7f7;
color: #545454;
}
/* NAVIGATION */
.navbar{
width: 100%;
height: 150px;
background: black;
position: fixed;
top: 0;
left: 0;
padding: 0 25px;
}
.navbar .inner_navbar{
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
height: 100%;
}
.navbar .hamburger{
display: none;
}
.navbar .menu ul{
display: flex;
}
.navbar .menu ul li a{
display: block;
width: 120px;
margin-right: 10px;
text-align: center;
font-size: 14px;
text-transform: uppercase;
color: #fff;
padding: 10px;
border-radius: 25px;
letter-spacing: 2px;
transition: all 0.2s ease;
}
.navbar .menu ul li:last-child a{
margin-right: 0;
}
.navbar .menu ul li a:hover,
.navbar .menu ul li a.active{
background: #5db485;
}
.container{
width: 100%;
max-width: 1906;
}
/*Tablet*/
#media (max-width: 992px){
.navbar{
height: 218px;
padding: 12px;
}
.navbar .inner_navbar{
flex-direction: column;
}
.container {
max-width: 991.98px;
}
}
/*Mobile*/
#media (max-width: 728px){
.navbar{
height: 150px;
}
.navbar .inner_navbar{
flex-direction: row;
}
.navbar .menu ul{
position: absolute;
top: 150px;
left: 0;
display: block;
background: orangered;
width: 100%;
}
.navbar .menu ul li{
padding: 10px;
}
.navbar .menu ul li a{
width: 100%;
padding: 12px;
}
.navbar .hamburger{
display: block;
position: absolute;
top: 15px;
right: 25px;
color: #fff;
font-size: 24px;
cursor: pointer;
transition: all 0.2s ease;
}
.navbar .menu{
display: none;
}
.navbar .menu.activate{
display: block;
}
.container{
max-width: 727.98px;
}
}
<!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>Home</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="wrapper">
<div class="navbar">
<div class="inner_navbar">
<div class="logo">
<img src="/images/Final Logo.png" style="width: 150px;">
</div>
<div class="menu">
<ul>
<li>Home</li>
<li>Desert Safari</li>
<li>Tours</li>
<li>Activities</li>
<li>Contact-Us</li>
</ul>
</div>
</div>
<div class="hamburger">
<img src="/images/menu-btn.png" style="width: 40px;">
</div>
<div class="container">
<img class="promo" src="https://www.arabian-adventures.com/on/demandware.static/-/Sites-dnata-UAE-Library/default/dw922d22bf/images/slider/luxury-desert-camping-arabian-adventures-1920x400.jpg" alt="">
</div>
</div>
</div>
<script>
var hamburger = document.querySelector(".hamburger");
var menu = document.querySelector(".menu");
hamburger.addEventListener("click", function(){
menu.classList.toggle("activate");
})
</script>
</body>
</html>
Use 100% width and set a max-width for each #media.
Important: use % in your main layout, not absolute pixels.
By using this the content will not overflow the .container
.container {
width: 100%;
max-width: 1906px;
}
#media (max-width: 992px) {
.container {
/* width 100% is set aboven*/
max-width: 991.98px;
}
}
#media (max-width: 728px) {
.container {
/* width 100% is set aboven*/
max-width: 727.98px;
}
}
I have any issue, i have been make some footer and when i test my new footer, the Footer covered the content and navbar. i still figure it out how to solve this problem. hope i can get some answer at here...
$(".togel.tblmenu").click(function () {
$(".menu").toggleClass("sh");
});
body {
min-height: 400px;
margin-bottom: 100px;
clear: both;
background: #eff2f7;
}
a {
left: -50;
text-decoration: none;
color: white;
display: block;
transition: 0.3s;
font-size: 20px
}
a:hover {
transition: 0.3s;
}
nav {
position: fixed;
top: 0;
left: 20px;
right: 0;
background: #1e77b0;
font-family: Palatino Linotype;
}
.title {
display: inline-block;
float: left;
line-height: 50px;
}
.menu {
display: inline-block;
float: left;
}
.menu ul {
list-style: none;
padding: 0;
margin: 0;
}
.menu ul li {
display: inline-block;
}
.menu ul li a {
padding: 0 50px;
display: block;
line-height: 50px;
}
.menu li:hover {
background-color: #009cff;
}
.wrap {
width: 95%;
margin: 0 auto;
}
.tblmenubox {
display: inline-block;
float: right;
line-height: 50px;
}
.tblmenu {
display: block;
position: absolute;
width: 25px;
height: 25px;
background: #1e77b0;
border-radius: 50%;
top: 50%;
transform: translateY(-50%);
}
.tblmenubox {
display: none;
visibility: hidden;
}
.kotakpersegi {
display: block;
position: absolute;
left: -40px;
width: 250px;
height: 50px;
background: #009cff;
transform: translateY(-50%);
-webkit-transform: skew(30deg);
-moz-transform: skew(30deg);
-o- transform: skew(30deg);
transform: skew(30deg)
}
.logo {
position: absolute;
left: 50px;
}
#media screen and (max-width:1000px) {
.kotakpersegi {
width: 150%;
}
.logo {
position: absolute;
float: center;
left: 25%;
}
.menu {
display: none;
}
.tblmenubox {
display: block;
visibility: visible;
}
.menu.sh {
display: block;
position: absolute;
top: 50px;
background: #1e77b0;
width: 100%;
left: 0;
}
.menu a:hover {
color: #eff2f7;
background: #009cff;
}
.menu ul li {
display: block;
text-align: center;
}
}
/*navbar code*/
.footer-bottom {
text-align: center;
background-color: #1e77b0;
width: 100%;
position: relative;
bottom: 50%;
}
.Footer-header h3 {
font-family: 'Roboto Condensed', sans-serif;
color: white;
margin: 20px;
text-align: left;
}
.Footer-Sponsored img {
height: 128px;
margin: 10px;
}
hr {
margin: 20px;
border: 0.5px solid lightblue;
}
.hr1 {
margin: 40px;
}
.Footer-deep {
margin: 30px;
}
.Footer-deep img {
height: 30px;
margin: 10px;
}
.Footer-deep h3 {
color: white;
font-family: 'Garamond', sans-serif;
font-size: 100%;
}
.content-wrapper { /* added a top margin */
margin-top: 50px; /* We know this is the height because it is applied specifically in CSS */
padding: 30px;
}
.content-wrapper h1 {
font-family: Palatino Linotype;
text-align: center;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- font -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght#1,300&display=swap" rel="stylesheet">
<!-- Navbar -->
<nav>
<div class="wrap">
<div class="title">
<div class="kotakpersegi">
<a href="">
<img class="logo" src="img/logo.png" width="180" height="50">
</a>
</div>
</div>
<div class="tblmenubox">
<div class="togel tblmenu">
</div>
</div>
<div class="menu">
<ul>
<li>Home</li>
<li>Contact</li>
<li>Service</li>
<li>Fiture</li>
<li>Maps</li>
</ul>
</div>
</div>
</nav>
<!-- Navbar -->
<div class="content-wrapper">
<h1>San Andreas Motor Racing Grand Prix</h1>
</div>
<!-- content stop here -->
<footer class="footer-bottom">
<div class="Footer-header">
<h2>San Andreas Motor Racing</h2>
<hr class="Light-line">
<h3>Sponsored By</h3>
</div>
<div class="Footer-Sponsored">
<img src="Sponsored/1.jpg">
<img src="Sponsored/2.png">
<img src="Sponsored/3.jpg">
</div>
<hr class="hr1">
<div class="Footer-deep">
<img src="img/logo.png" align="left">
<h3 align="right">San Andreas Motor Racing Championship</h3>
</div>
</footer>
i have tried to change the position to relative absolute or whatever but it make me found another problem. maybee some one can help me to fix this problem, please.... i have been try to solve his problem by googling for a day and still doesn't have any clue about this problem...
Just add z-index:10 to nav css style
body {
min-height: 400px;
margin-bottom: 100px;
clear: both;
background: #eff2f7;
}
a {
left: -50;
text-decoration: none;
color: white;
display: block;
transition: 0.3s;
font-size: 20px
}
a:hover {
transition: 0.3s;
}
nav {
position: fixed;
top: 0;
left: 20px;
right: 0;
background: #1e77b0;
font-family: Palatino Linotype;
z-index:10;
}
.title {
display: inline-block;
float: left;
line-height: 50px;
}
.menu {
display: inline-block;
float: left;
}
.menu ul {
list-style: none;
padding: 0;
margin: 0;
}
.menu ul li {
display: inline-block;
}
.menu ul li a {
padding: 0 50px;
display: block;
line-height: 50px;
}
.menu li:hover {
background-color: #009cff;
}
.wrap {
width: 95%;
margin: 0 auto;
}
.tblmenubox {
display: inline-block;
float: right;
line-height: 50px;
}
.tblmenu {
display: block;
position: absolute;
width: 25px;
height: 25px;
background: #1e77b0;
border-radius: 50%;
top: 50%;
transform: translateY(-50%);
}
.tblmenubox {
display: none;
visibility: hidden;
}
.kotakpersegi {
display: block;
position: absolute;
left: -40px;
width: 250px;
height: 50px;
background: #009cff;
transform: translateY(-50%);
-webkit-transform: skew(30deg);
-moz-transform: skew(30deg);
-o- transform: skew(30deg);
transform: skew(30deg)
}
.logo {
position: absolute;
left: 50px;
}
#media screen and (max-width:1000px) {
.kotakpersegi {
width: 150%;
}
.logo {
position: absolute;
float: center;
left: 25%;
}
.menu {
display: none;
}
.tblmenubox {
display: block;
visibility: visible;
}
.menu.sh {
display: block;
position: absolute;
top: 50px;
background: #1e77b0;
width: 100%;
left: 0;
}
.menu a:hover {
color: #eff2f7;
background: #009cff;
}
.menu ul li {
display: block;
text-align: center;
}
}
/*navbar code*/
.footer-bottom {
text-align: center;
background-color: #1e77b0;
width: 100%;
position: relative;
bottom: 50%;
}
.Footer-header h3 {
font-family: 'Roboto Condensed', sans-serif;
color: white;
margin: 20px;
text-align: left;
}
.Footer-Sponsored img {
height: 128px;
margin: 10px;
}
hr {
margin: 20px;
border: 0.5px solid lightblue;
}
.hr1 {
margin: 40px;
}
.Footer-deep {
margin: 30px;
}
.Footer-deep img {
height: 30px;
margin: 10px;
}
.Footer-deep h3 {
color: white;
font-family: 'Garamond', sans-serif;
font-size: 100%;
}
.content-wrapper { /* added a top margin */
margin-top: 50px; /* We know this is the height because it is applied specifically in CSS */
padding: 30px;
}
.content-wrapper h1 {
font-family: Palatino Linotype;
text-align: center;
}
<!DOCTYPE html>
<html>
<head>
<title>SA-MR</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- CSS document -->
<link rel="stylesheet" type="text/css" href="css/SAMRnavbar.css">
<meta charset="utf-8">
<!-- font -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght#1,300&display=swap" rel="stylesheet">
</head>
<body>
<!-- Navbar -->
<nav>
<div class="wrap">
<div class="title">
<div class="kotakpersegi">
<a href="">
<img class="logo" src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/11/Test-Logo.svg/1175px-Test-Logo.svg.png" width="180" height="50">
</a>
</div>
</div>
<div class="tblmenubox">
<div class="togel tblmenu">
</div>
</div>
<div class="menu">
<ul>
<li>Home</li>
<li>Contact</li>
<li>Service</li>
<li>Fiture</li>
<li>Maps</li>
</ul>
</div>
</div>
</nav>
<script src="js/jquery.min.js"></script>
<script type="text/javascript">
$(".togel.tblmenu").click(function () {
$(".menu").toggleClass("sh");
});
</script>
<!-- Navbar -->
<div class="content-wrapper">
<h1>San Andreas Motor Racing Grand Prix</h1>
</div>
<!-- content stop here -->
<footer class="footer-bottom">
<div class="Footer-header">
<h2>San Andreas Motor Racing</h2>
<hr class="Light-line">
<h3>Sponsored By</h3>
</div>
<div class="Footer-Sponsored">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/11/Test-Logo.svg/1175px-Test-Logo.svg.png">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/11/Test-Logo.svg/1175px-Test-Logo.svg.png">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/11/Test-Logo.svg/1175px-Test-Logo.svg.png">
</div>
<hr class="hr1">
<div class="Footer-deep">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/11/Test-Logo.svg/1175px-Test-Logo.svg.png" align="left">
<h3 align="right">San Andreas Motor Racing Championship</h3>
</div>
</footer>
</body>
</html>
This can be resolved by adding 'z-index: -1;' to your footer-bottom class.
Learn more about z-indexing here
In the most basic cases, HTML pages can be considered two-dimensional, because text, images, and other elements are arranged on the page without overlapping. In this case, there is a single rendering flow, and all elements are aware of the space taken by others. The z-index attribute lets you adjust the order of the layering of objects when rendering content.
In addition to their horizontal and vertical positions, boxes lie along a "z-axis" and are formatted one on top of the other. Z-axis positions are particularly relevant when boxes overlap visually.
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index
You should change the z-order of your elements.
Set z-index of footer less than z-index of the navbar (enough set z-index: -1 for footer)
More info:
https://developer.mozilla.org/en-US/docs/Web/CSS/z-index
I have tried literally everything to try and make the exit icon show up on the menu by giving it an index of 999 but still no luck in making it show, any idea why it is not working?
I have added the JavaScript as well.
menuBtn.addEventListener('click' , () => {
const menu = document.querySelectorAll('.menu');
for(let el of menu){
el.style.display = 'block'
}
})
/*Navbar*/
.navbar {
width: 100%;
position: fixed;
font-family: "Ubuntu", sans-serif;
padding: 30px 0;
}
.navbar .logo a {
font-size: 2rem;
font-weight: 600;
color: white;
}
.navbar .logo a span {
color: crimson;
transition: all 0.3s ease;
}
.sticky {
padding: 30px 0;
background-color: crimson;
}
.sticky .logo a span {
color: #fff;
}
.menu li {
display: inline-block;
list-style: none;
}
.menu li a {
color: #fff;
font-size: 1.1rem;
font-weight: 500;
margin-left: 35px;
padding-left: 5px;
transition: color 0.3s ease;
}
.menu li a:hover {
border-left: 3px solid white;
color: crimson;
}
.sticky .menu li a:hover {
color: white;
}
.navbar .max-width {
display: flex;
align-items: center;
justify-content: space-between;
}
.max-width {
max-width: 1300px;
padding: 0 80px;
margin: auto;
}
/*Menu Button*/
.fa.fa-bars.menuBtn {
color: #fff;
font-size: 35px;
cursor: pointer;
display: none;
}
.fa.fa-times-circle.exit {
color: white;
font-size: 35px;
cursor: pointer;
display: none;
}
#media (max-width: 934px) {
.max-width {
padding: 0 50px;
}
.fa.fa-bars.menuBtn {
display: block;
padding-left: 10em;
}
.menu {
position: fixed;
height: 100vh;
width: 100%;
left: 0;
top: 0;
background-color: #111;
text-align: center;
padding-top: 110px;
display: none;
}
.fa.fa-times-circle.exit {
z-index: 999;
display: none;
margin: 1.8rem;
}
.menu ul li {
display: block;
}
.menu ul li a {
display: inline-block;
margin: 20px 0;
font-size: 35px;
}
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/#fortawesome/fontawesome-free#5.15.3/css/fontawesome.min.css" integrity="sha384-wESLQ85D6gbsF459vf1CiZ2+rr+CsxRY0RpiF1tLlQpDnAgg6rwdsUF1+Ics2bni" crossorigin="anonymous">
<header>
<nav class="navbar" id="nav">
<div class="max-width">
<div class="logo"><a id="headSpan" href="index.html">Port<span>folio.</span></a></div>
<div class="menu">
<ul>
<li>Home</li>
<li>About</li>
<li>Skills</li>
<li>Projects</li>
<li>CV</li>
<li>Contact</li>
</ul>
</div>
<div>
<i class="fa fa-bars menuBtn" id="menuBtn" aria-hidden="true"></i>
<i class="fa fa-times-circle exit" id="exitBtn" aria-hidden="true"></i>
</div>
</div>
</nav>
<!--Head Banner-->
<section class="home" id="home">
<div class="max-width">
<div class="home-content">
<div class="text-1">Hello, my name is</div>
<div class="text-2">Hadi Zouhbi</div>
<div class="text-3">And I'm a <span id="headSpan"><Developer></Developer></span></div>
</div>
</div>
</section>
</header>
Because it never made display:block when enter in small screen like you did for menubtn.
.fa.fa-bars.menuBtn {
display: block;
padding-left: 10em;
}
Do the same for exit icon under #media (max-width: 934px) also
.fa.fa-times-circle.exit {
display: inline-block;
}
And remove this code
.fa.fa-times-circle.exit {
z-index: 999;
display: none;
margin: 1.8rem;
}
Working example:
/*Navbar*/
body {
background-color: #ccc;
}
.navbar {
width: 100%;
position: fixed;
font-family: "Ubuntu", sans-serif;
padding: 30px 0;
}
.navbar .logo a {
font-size: 2rem;
font-weight: 600;
color: white;
}
.navbar .logo a span {
color: crimson;
transition: all 0.3s ease;
}
.sticky {
padding: 30px 0;
background-color: crimson;
}
.sticky .logo a span {
color: #fff;
}
.menu li {
display: inline-block;
list-style: none;
}
.menu li a {
color: #fff;
font-size: 1.1rem;
font-weight: 500;
margin-left: 35px;
padding-left: 5px;
transition: color 0.3s ease;
}
.menu li a:hover {
border-left: 3px solid white;
color: crimson;
}
.sticky .menu li a:hover {
color: white;
}
.navbar .max-width {
display: flex;
align-items: center;
justify-content: space-between;
}
.max-width {
max-width: 1300px;
padding: 0 80px;
margin: auto;
}
/*Menu Button*/
.fa.fa-bars.menuBtn {
color: #fff;
font-size: 35px;
cursor: pointer;
display: none;
}
.fa.fa-times-circle.exit {
color: white;
font-size: 35px;
cursor: pointer;
display: none;
}
#media (max-width: 934px) {
.max-width {
padding: 0 50px;
}
.fa.fa-bars.menuBtn {
display: block;
padding-left: 10em;
}
.fa.fa-times-circle.exit {
display: inline-block;
}
.menu {
position: fixed;
height: 100vh;
width: 100%;
left: 0;
top: 0;
background-color: #111;
text-align: center;
padding-top: 110px;
display: none;
}
.menu ul li {
display: block;
}
.menu ul li a {
display: inline-block;
margin: 20px 0;
font-size: 35px;
}
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/#fortawesome/fontawesome-free#5.15.3/css/fontawesome.min.css" integrity="sha384-wESLQ85D6gbsF459vf1CiZ2+rr+CsxRY0RpiF1tLlQpDnAgg6rwdsUF1+Ics2bni" crossorigin="anonymous">
<header>
<nav class="navbar" id="nav">
<div class="max-width">
<div class="logo"><a id="headSpan" href="index.html">Port<span>folio.</span></a></div>
<div class="menu">
<ul>
<li>Home</li>
<li>About</li>
<li>Skills</li>
<li>Projects</li>
<li>CV</li>
<li>Contact</li>
</ul>
</div>
<div>
<i class="fa fa-bars menuBtn" id="menuBtn" aria-hidden="true"></i>
<i class="fa fa-times-circle exit" id="exitBtn" aria-hidden="true"></i>
</div>
</div>
</nav>
<!--Head Banner-->
<section class="home" id="home">
<div class="max-width">
<div class="home-content">
<div class="text-1">Hello, my name is</div>
<div class="text-2">Hadi Zouhbi</div>
<div class="text-3">And I'm a <span id="headSpan"><Developer></Developer></span></div>
</div>
</div>
</section>
</header>
I added a link to the logo(image) on the navbar, but when I go to the page the whole navbar apart from the links becomes the link. How do I make it so that it only applies to the image?
As per comments I have uipdated the code with CSS and JS. I'm very new to web development, this may explain my lack of knowledge and overuse of CSS.
the image.
function navHamburger() {
var x = document.getElementById("nav-links");
if (x.style.display === "block") {
x.style.display = "none";
} else {
x.style.display = "block";
}
}
nav {
background-color: #fff;
}
.nav-row {
/* margin: 0; */
overflow: hidden;
position: relative;
padding: 10px;
}
.nav-row #nav-links {
display: none;
}
.nav-row a {
color: #0075b2;
text-decoration: none;
font-weight: 500;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
text-align: center;
text-transform: uppercase;
padding: 20px;
}
.nav-row a.icon {
font-size: 200%;
display: block;
position: absolute;
right: 0;
top: 0;
margin-top: 0.1em;
margin-right: 25px;
}
.nav-row a:hover {
color: #19afff;
}
.main-nav {
text-decoration: none;
list-style: none;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-ms-flex-direction: row;
flex-direction: row;
}
.mobile-menu {
text-decoration: none;
list-style: none;
}
.main-nav li a:link,
.main-nav li a:visited {
color: #0075b2;
text-decoration: none;
text-transform: uppercase;
font-size: 150%;
font-weight: 500;
padding: 4px;
}
.main-nav li a:hover,
.main-nav li a:active {
border-top: 2px solid #b36500;
border-bottom: 2px solid #b36500;
-webkit-transition: border-bottom 0.2s;
-o-transition: border-bottom 0.2s;
transition: border-bottom 0.2s;
}
#media (min-width: 601px) {
.mobile-menu {
display: none;
}
}
.desktop-menu {
display: none;
right: 0;
top: 0;
}
#media (min-width: 601px) {
.desktop-menu {
display: block;
position: absolute;
margin-top: 30px;
margin-right: 10px;
}
.nav-row {
margin-right: 20px;
}
.nav-row a {
margin-left: 20px;
}
}
#media (min-width: 901px) {
.desktop-menu {
margin-top: 50px;
margin-right: 10px;
}
}
#media (min-width: 1290px) {
.desktop-menu {
margin-top: 70px;
margin-right: 10px;
}
}
<nav>
<div class="nav-row">
<div>
<a href="index.html">
<img
src="resources/img/logo/fullLogo.svg"
alt="Archer Civils & Construction Logo"
class="logo"
/>
</a>
</div>
<div class="mobile-menu">
<div id="nav-links">
Civils
Fencing
Contact
</div>
<a
href="javascript:void(0);"
class="icon hamburger-icon"
onclick="navHamburger()"
>
<i class="fa fa-bars"></i>
</a>
</div>
<div class="desktop-menu">
<ul class="main-nav">
<li>Civils</li>
<li>Fencing</li>
<li>Contact </li>
</ul>
</div>
</div>
</nav>
You're using flex for the main nav class, which takes full inline value:
fiddle to playaround.
nav {
background-color: #fff;
}
.nav-row {
/* margin: 0; */
overflow: hidden;
position: relative;
padding: 10px;
}
.nav-row #nav-links {
display: none;
}
img {
height: 100px;
width: 100px;
}
.nav-row a {
color: #0075b2;
text-decoration: none;
font-weight: 500;
text-align: center;
text-transform: uppercase;
padding: 20px;
}
.nav-row a.icon {
font-size: 200%;
display: block;
position: absolute;
right: 0;
top: 0;
margin-top: 0.1em;
margin-right: 25px;
}
.nav-row a:hover {
color: #19afff;
}
.main-nav {
text-decoration: none;
list-style: none;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-ms-flex-direction: row;
flex-direction: row;
}
.mobile-menu {
text-decoration: none;
list-style: none;
}
.main-nav li a:link,
.main-nav li a:visited {
color: #0075b2;
text-decoration: none;
text-transform: uppercase;
font-size: 150%;
font-weight: 500;
padding: 4px;
}
.main-nav li a:hover,
.main-nav li a:active {
border-top: 2px solid #b36500;
border-bottom: 2px solid #b36500;
-webkit-transition: border-bottom 0.2s;
-o-transition: border-bottom 0.2s;
transition: border-bottom 0.2s;
}
#media (min-width: 601px) {
.mobile-menu {
display: none;
}
}
.desktop-menu {
display: none;
right: 0;
top: 0;
}
#media (min-width: 601px) {
.desktop-menu {
display: block;
position: absolute;
margin-top: 30px;
margin-right: 10px;
}
.nav-row {
margin-right: 20px;
}
.nav-row a {
margin-left: 20px;
}
}
#media (min-width: 901px) {
.desktop-menu {
margin-top: 50px;
margin-right: 10px;
}
}
#media (min-width: 1290px) {
.desktop-menu {
margin-top: 70px;
margin-right: 10px;
}
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.0/css/bootstrap.min.css" rel="stylesheet" />
<nav>
<div class="nav-row">
<div>
<a href="index.html">
<img src="http://placekitten.com/301/301" alt="Archer Civils & Construction Logo" class="logo" />
</a>
</div>
<div class="mobile-menu">
<div id="nav-links">
Civils
Fencing
Contact
</div>
<a href="javascript:void(0);" class="icon hamburger-icon" onclick="navHamburger()">
<i class="fa fa-bars"></i>
</a>
</div>
<div class="desktop-menu">
<ul class="main-nav">
<li>Civils</li>
<li>Fencing</li>
<li>Contact </li>
</ul>
</div>
</div>
</nav>
"display:flex" is the culprit here. Due to "display:flex" css property on the link, link is taking complete line. But it is not like that other navigation items has also turned into link but because link is taking the complete width and layered above the other navigation items it must be giving feel like other navigation items has also become a same link. You can refer the below screenshot:
Here is the code of it:
<!DOCTYPE html>
<html>
<head>
<style>
.logo-link {
display: flex;
cursor: pointer
}
.logo-link img {
max-height: 200px;
}
</style>
</head>
<body>
<nav>
<a class="logo-link" href=""><img
src="https://i.pinimg.com/736x/5b/b4/8b/5bb48b07fa6e3840bb3afa2bc821b882.jpg"></a>
<div>
<ul>
<li>Item1</li>
<li>Item2</li>
</ul>
</div>
</nav>
</body>
</html>
You can create your code like this to resolve this issue:
<!DOCTYPE html>
<html>
<head>
<style>
nav {
width: 100%;
height: 100px;
background-color: bisque;
box-sizing: border-box;
display: flex;
align-items: center;
}
nav .align-left {
margin-left: 10px;
margin-right: auto;
height: 90%;
}
nav .align-right {
margin-left: auto;
margin-right: 10px;
height: 100%;
display: flex;
justify-content: space-between;
width: 11%;
height: 20%;
}
nav .logo-link>img {
height: 100%;
}
</style>
</head>
<body>
<nav>
<div class="align-left">
<a class="logo-link" href=""><img
src="https://i.pinimg.com/736x/5b/b4/8b/5bb48b07fa6e3840bb3afa2bc821b882.jpg"></a>
</div>
<div class="align-right">
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
</div>
</nav>
</body>
</html>
Just insert tour image tag inside the anchor tag like this:
Text