How do i create a mobile first responsive header - html

Please offer some advice and suggestions as to how to enable a mobile first responsive header. i cant seem to keep my content to the left when at mobile screen size also i need the header and back button to be the same size. Also when at a full screen size the header area doesn't spread. i use Flex-box but finding it difficult to align this particular content in the header. Any advise suggestions would be more than appreciated.
.header {
display: flex;
justify-content: space-between;
background: #633;
padding: 10px 10px;
}
.header a {
float: left;
color: black;
text-align: center;
padding: 12px;
text-decoration: none;
font-size: 18px;
line-height: 25px;
border-radius: 4px;
}
.header a.logo {
font-size: 25px;
font-weight: bold;
justify-content: center;
}
.header a:hover {
color: black;
}
.logo {
display: flex;
align-items: flex-start;
transition: background 250ms ease-in-out, transform 150ms ease;
-webkit-appearance: none;
-moz-appearance: none;
}
.home-button {
display: inline-block;
border: none;
padding: 1rem 2rem;
margin-right: 20px;
border-radius: 4px;
text-decoration: none;
background: dodgerblue;
color: #ffffff;
font-family: sans-serif;
font-size: 1rem;
cursor: pointer;
text-align: center;
transition: background 250ms ease-in-out, transform 150ms ease;
-webkit-appearance: none;
-moz-appearance: none;
}
.header-right {
float: right;
}
a.home-button:hover,
a.home-button:focus {
background: #434344;
}
#media only screen and (min-width: 300px) {
.header,
.header a,
.home-button,
.logo {
display: flex;
justify-content: flex-start;
float: none;
display: block;
padding: 5px;
}
.header-right {
float: none;
}
}
/* end of header*/
/***********************************************
**********************************************
*********************************************/
/* Back button CSS*/
.button {
display: inline-block;
border: none;
padding: 1rem 2rem;
margin-right: 20px;
border-radius: 4px;
text-decoration: none;
background: dodgerblue;
color: #ffffff;
font-family: sans-serif;
font-size: 1rem;
cursor: pointer;
text-align: center;
transition: background 250ms ease-in-out, transform 150ms ease;
-webkit-appearance: none;
-moz-appearance: none;
}
.button:hover,
.button:focus {
background: #434344;
}
.button:focus {
outline: 1px solid #fff;
outline-offset: -4px;
}
.button:active {
transform: scale(0.99);
}
<div class="header">
<div class="header-right">
<img src="images/cw_logo.png" alt="company-logo">
<a class="home-button" href="#home">Home</a>
<a class="email" href="email#emailyou.com">email#emailyou.com</a>
<a href="#about">
<p>1234567890</p>
</a>
<button class="button" onclick="goBack()">Go Back</button>
</div>
</div>

Related

My Hamburger menu navigation isnt closing after clicking on link

I followed youtube tutorial, becouse I a m new and still learning front-end. When the menu is on deskop resolution, it is in a line, but when it gets to mobile resolution it changes to hamburger menu. Is is working fine, but after I click some link, I want it to close, becouse otherwise you cant see the content of the page.
nav {
height: 75px;
width: 100%;
background-color: #171c1f;
display: flex;
justify-content: space-between;
z-index: 99;
}
.logo-container {
display: flex;
align-items: center;
width: auto;
margin: 0;
}
.logo-txt {
font-size: 35px;
line-height: 75px;
padding-left: 30px;
font-family: 'Signika Negative', sans-serif;
font-weight: bold;
color: rgb(255, 255, 255);
cursor: pointer;
}
.nav-list {
position: fixed;
width: 100%;
height: 0vh;
top: 75px;
background: #4a499e;
float: right;
text-align: center;
transition: all .5s;
z-index: 2;
}
.nav-list li {
opacity: 0;
line-height: 30px;
margin: 50px 0;
transition: all .5s;
}
.nav-list li a {
color: #fff;
font-size: 27.5px;
text-transform: uppercase;
text-decoration: none;
font-weight: 900;
transition: .5s;
}
.nav-list li a.active,.nav-list li a:hover{
color: #00b1f7;
transition: 0.5s;
}
.hamburger-btn {
display: block;
font-size: 30px;
color: white;
float: right;
line-height: 75px;
margin-right: 40px;
cursor: pointer;
}
#check {
display: none;
}
#check:checked ~ .nav-list {
height: 100vh;
}
#check:checked ~ .nav-list li {
opacity: 1;
}
#media only screen and (min-width: 1100px) {
nav{
height: 100px;
background-color: transparent;
}
.hamburger-btn{
display: none;
}
.nav-list {
position: relative;
height: 100px;
top: 0;
background: none;
float: right;
text-align: right;
margin-right: 25px;
transition: none;
text-shadow: 2px 2px 3px #00b1f7;
}
.nav-list li a {
color: rgb(0, 0, 0);
font-size: 27.5px;
text-transform: uppercase;
text-decoration: none;
font-weight: 900;
}
.nav-list li{
display: inline-block;
opacity: 1;
line-height: 100px;
margin: 0 20px;
transition: none;
}
.nav-list li a.active, .nav-list li a:hover {
color: #00b1f7;
text-shadow: 1px 1px #000000;
}
.logo-txt {
font-size: 35px;
line-height: 75px;
padding-left: 30px;
font-family: 'Signika Negative', sans-serif;
font-weight: bold;
color: rgb(0, 0, 0);
cursor: pointer;
}
}
<header>
<nav>
<div class="logo-container">
<label class="logo-txt">Autirock</label>
</div>
<input type="checkbox" id="check">
<label for="check" class="hamburger-btn">
<i class="fas fa-bars"></i>
</label>
<ul class="nav-list">
<li><a class="active" href="#banner">DOMŮ</a></li>
<li>SLUŽBY A POMŮCKY</li>
<li>O MNĚ</li>
<li>CENÍK</li>
<li>KONTAKT</li>
</ul>
</nav>
</header>
That's a nice idea for hamburger menu. But you will need javascript to close it when clicking on a link. That's what I did. It is operated using a checkbox, so I unchecked it.
document.querySelectorAll(".nav-list li a").forEach(function(elem) {
elem.addEventListener('click', function(ev) {
document.getElementById("check").checked = false;
});
})
nav {
height: 75px;
width: 100%;
background-color: #171c1f;
display: flex;
justify-content: space-between;
z-index: 99;
}
.logo-container {
display: flex;
align-items: center;
width: auto;
margin: 0;
}
.logo-txt {
font-size: 35px;
line-height: 75px;
padding-left: 30px;
font-family: 'Signika Negative', sans-serif;
font-weight: bold;
color: rgb(255, 255, 255);
cursor: pointer;
}
.nav-list {
position: fixed;
width: 100%;
height: 0vh;
top: 75px;
background: #4a499e;
float: right;
text-align: center;
transition: all .5s;
z-index: 2;
}
.nav-list li {
opacity: 0;
line-height: 30px;
margin: 50px 0;
transition: all .5s;
}
.nav-list li a {
color: #fff;
font-size: 27.5px;
text-transform: uppercase;
text-decoration: none;
font-weight: 900;
transition: .5s;
}
.nav-list li a.active,
.nav-list li a:hover {
color: #00b1f7;
transition: 0.5s;
}
.hamburger-btn {
display: block;
font-size: 30px;
color: white;
float: right;
line-height: 75px;
margin-right: 40px;
cursor: pointer;
}
#check {
display: none;
}
#check:checked~.nav-list {
height: 100vh;
}
#check:checked~.nav-list li {
opacity: 1;
}
#media only screen and (min-width: 1100px) {
nav {
height: 100px;
background-color: transparent;
}
.hamburger-btn {
display: none;
}
.nav-list {
position: relative;
height: 100px;
top: 0;
background: none;
float: right;
text-align: right;
margin-right: 25px;
transition: none;
text-shadow: 2px 2px 3px #00b1f7;
}
.nav-list li a {
color: rgb(0, 0, 0);
font-size: 27.5px;
text-transform: uppercase;
text-decoration: none;
font-weight: 900;
}
.nav-list li {
display: inline-block;
opacity: 1;
line-height: 100px;
margin: 0 20px;
transition: none;
}
.nav-list li a.active,
.nav-list li a:hover {
color: #00b1f7;
text-shadow: 1px 1px #000000;
}
.logo-txt {
font-size: 35px;
line-height: 75px;
padding-left: 30px;
font-family: 'Signika Negative', sans-serif;
font-weight: bold;
color: rgb(0, 0, 0);
cursor: pointer;
}
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.2/css/all.min.css" integrity="sha512-1sCRPdkRXhBV2PBLUdRb4tMg1w2YPf37qatUFeS7zlBy7jJI8Lf4VHwWfZZfpXtYSLy85pkm9GaYVYMfw5BC1A==" crossorigin="anonymous" referrerpolicy="no-referrer"
/>
<header>
<nav>
<div class="logo-container">
<label class="logo-txt">Autirock</label>
</div>
<input type="checkbox" id="check">
<label for="check" class="hamburger-btn">
<i class="fas fa-bars"></i>
</label>
<ul class="nav-list">
<li><a class="active" href="#banner">DOMŮ</a></li>
<li>SLUŽBY A POMŮCKY</li>
<li>O MNĚ</li>
<li>CENÍK</li>
<li>KONTAKT</li>
</ul>
</nav>
</header>

Moving the navigation buttons to the left and the logo to the right

I would like to move the navigation buttons a little bit to the left and separate it from the last button which's Sign Up, at the same time, I need to move the logo a little bit to the right.
body {
margin: 0;
}
header {
background-color: rgb(212, 209, 209);
display: flex;
flex-wrap: wrap;
/* so navbar will go under logo on small smartphones */
align-items: baseline;
padding: 0.5rem;
justify-content: space-between;
}
.logo {
width: 100px;
margin-top: 16px;
cursor: pointer;
}
.nav {
display: flex;
gap: 1rem;
padding: 0;
}
.link {
background: none;
border: none;
text-decoration: none;
color: #777;
font-family: inherit;
font-size: inherit;
cursor: pointer;
padding: 0;
}
.link:hover {
color: black;
}
.dropdown {
position: relative;
}
.dropdown-menu {
position: absolute;
}
#signup {
padding: 10px 25px;
background-color: rgba(0, 136, 169, 1);
border: none;
border-radius: 50px;
cursor: pointer;
transition: all 0.3s ease 0s;
}
<header>
<img class="logo" src="images/new logo.png" alt="logo">
<nav class="nav">
<div class="dropdown">
<button class="link">Information</button>
<div class="dropdown-menu">Dropdown Content</div>
</div>
Pricing
<button class="link">Login</button>
<button class="link" id="signup">Sign Up</button>
</nav>
</header>
Just add a margin-left to your logo to move it more to the right. If you want more space between the last button and the rest of the content you can also add a margin-left to the .link:last-child If you want elements to space apart then use margin. margin: auto will distribute all remaining space within flexbox and css-grid (just as a side note for the future):
.logo {
margin-left: 25px;
}
.link:last-child {
margin-left: 30px;
}
/* original CSS */
body {
margin: 0;
}
header {
background-color: rgb(212, 209, 209);
display: flex;
flex-wrap: wrap;
/* so navbar will go under logo on small smartphones */
align-items: baseline;
padding: 0.5rem;
justify-content: space-between;
}
.logo {
width: 100px;
margin-top: 16px;
cursor: pointer;
}
.nav {
display: flex;
gap: 1rem;
padding: 0;
}
.link {
background: none;
border: none;
text-decoration: none;
color: #777;
font-family: inherit;
font-size: inherit;
cursor: pointer;
padding: 0;
}
.link:hover {
color: black;
}
.dropdown {
position: relative;
}
.dropdown-menu {
position: absolute;
}
#signup {
padding: 10px 25px;
background-color: rgba(0, 136, 169, 1);
border: none;
border-radius: 50px;
cursor: pointer;
transition: all 0.3s ease 0s;
}
<header>
<img class="logo" src="images/new logo.png" alt="logo">
<nav class="nav">
<div class="dropdown">
<button class="link">Information</button>
<div class="dropdown-menu">Dropdown Content</div>
</div>
Pricing
<button class="link">Login</button>
<button class="link" id="signup">Sign Up</button>
</nav>
</header>
body {
margin: 0;
}
header {
background-color: rgb(212, 209, 209);
display: flex;
flex-wrap: wrap; /* so navbar will go under logo on small smartphones */
align-items: inherit;
padding: 15px 4%;
justify-content: space-between;
}
.logo {
margin-left: 20px;
cursor: pointer;
}
.nav {
display: flex;
gap: 1rem;
padding: 0;
}
.link {
background: none;
border: none;
text-decoration: none;
color: #777;
font-family: inherit;
font-size: inherit;
cursor: pointer;
padding: 0;
}
.link:hover {
color: black;
}
.link:last-child {
margin: auto;
}
.dropdown {
position: relative;
}
.dropdown-menu {
position: absolute;
}
#signup {
padding: 10px 25px;
background-color: rgba(0,136,169,1);
border: none;
border-radius: 50px;
cursor: pointer;
transition: all 0.3s ease 0s;
}
If you want to move the logo to the right and signup to the left seperated from other navigation buttons then since its the first and last child, just use:
header:first-child{
float: right;
}
header:last-child{
float: left;
}
To adjust the middle buttons, just give a little bit of margin to position it correctly
give them all a little bit of margin in your css file. That's all I can tell you without seeing your CSS file

Navigationbar dropdown menu weird placement

I'm trying to make a dropdown menu to my navigation bar but when I hover over the London tab, the dropdown menu is slightly placed to the right. I have no idea as to why this is happening, and I've tried some solutions but they have not been successful.
I dont know how to make the dropdown menu centered so its just below the London tab. Any help or advice would be appriciated!
body {
font-family: Arial;
}
.navbar {
display: flex;
margin-bottom: 0px;
justify-content: center;
gap: 50px;
padding: 1em;
padding-bottom: 4em;
padding-top: 1.5em;
}
.navbar a {
color: white;
padding: 14px 20px;
text-decoration: none;
padding: 2em;
padding-top: 1em;
padding-bottom: 1em;
background-color: #333;
border-radius: 5px;
transition: 0.2s;
}
.navbar a:hover {
background-color: whitesmoke;
color: black;
}
.active-dropdown {
display: flex;
flex-wrap: wrap;
flex-direction: column;
position: relative;
}
.active-dropdown {
color: white;
padding: 14px 20px;
text-decoration: none;
padding: 2em;
padding-top: 1em;
padding-bottom: 1em;
background-color: #04AA6D !important;
border-radius: 5px;
transition: 0.2s;
}
.active-dropdown a{
display: block;
background-color: #11c784 !important;
color: white;
text-decoration: none;
padding: 2em;
padding-top: 1em;
padding-bottom: 1em;
border-radius: 5px;
transition: 0.2s;
}
.active-dropdown > .dropdown-sub{
display: none;
z-index: 1;
flex-direction: column;
position: absolute;
top: 50px;
background: rgb(4, 199, 129);
color: white;
border-radius: 5px;
transition: 0.2s;
width: 100%;
}
.active-dropdown:hover > .dropdown-sub {
display: flex;
}
.dropdown-option a:hover{
background-color: #abcdef !important;
}
.active-dropdown a:hover {
color: white;
transform: scale(1);
}
<!DOCTYPE html>
<html>
<head>
<title>City</title>
<link href="london.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="navbar">
<div class="active-dropdown">
<div class="dropdown-title">London</div>
<div class="dropdown-sub">
<div class="dropdown-option">Overview</div>
<div class="dropdown-option">Wikipedia</div>
<div class="dropdown-option">Pictures</div>
</div>
</div>
<a style="align-self: flex-start" href="#">Paris</a>
<a style="align-self: flex-start" href="#">Tokyo</a>
</div>
The problem is, when position:absolute is used, the default for "right" is not 0.
Source:
What are the default top, left, botton or right values when position:absolute is used?
This should fix the problem:
.active-dropdown > .dropdown-sub {
right: 0px;
}
A very simple solution would be to add this to your code:
.active-dropdown > .dropdown-sub{
display: none;
z-index: 1;
flex-direction: column;
position: absolute;
top: 50px;
background: rgb(4, 199, 129);
color: white;
border-radius: 5px;
transition: 0.2s;
width: 100%;
left: 0px; /* add this */
}
At first, you should add left:0px. I recommend using percentages instead. In the future, you do not need to edit again if the size or padding changes.
.active-dropdown > .dropdown-sub{
display: none;
z-index: 1;
flex-direction: column;
position: absolute;
top: 100%; /* Changed */
left: 0%; /* Changed */
background: rgb(4, 199, 129);
color: white;
border-radius: 5px;
transition: 0.2s;
width: 100%;
}

Navbar links not getting smaller

I am having an issue with my navbar, once I make the browser tab smaller, the text stays the same size but the logo gets smaller and smaller and disappears. How can I make it so everything gets smaller? If any more information is needed I will provide them. Here are some examples of my problem.
100% width page vs Page made smaller for smaller screens for example
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
/* custom scroll bar */
::-webkit-scrollbar {
width: 10px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
background: #888;
}
::selection {
background: rgb(0, 123, 255, 0.3);
}
.content {
max-width: 1250px;
margin: auto;
padding: 0 30px;
}
/* Nav start*/
.navbar {
position: fixed;
width: 100%;
z-index: 2;
padding: 25px 0;
transition: all 0.3s ease;
background-color: black;
}
.navbar.sticky {
background: black;
padding: 10px 0;
box-shadow: 0px 3px 5px 0px rgba(0, 0, 0, 0.1);
}
.navbar .content {
display: flex;
align-items: center;
justify-content: space-between;
}
.navbar .logo a {
color: #fff;
font-size: 30px;
font-weight: 600;
text-decoration: none;
}
.navbar .menu-list {
display: inline-flex;
}
.menu-list li {
list-style: none;
}
.menu-list li a {
color: #fff;
font-size: 18px;
font-weight: 500;
margin-left: 20px;
text-decoration: none;
transition: all 0.3s ease;
}
.menu-list li a:hover {
color: #007bff;
}
.banner {
height: 100vh;
background-position: center;
background-attachment: fixed;
}
.about {
padding: 30px 0;
}
.about .title {
font-size: 38px;
font-weight: 700;
}
.about p {
padding-top: 20px;
text-align: justify;
}
.icon {
color: #fff;
font-size: 20px;
cursor: pointer;
display: none;
}
.menu-list .cancel-btn {
position: absolute;
right: 30px;
top: 20px;
}
#media (max-width: 1230px) {
.content {
padding: 0 60px;
}
}
#media (max-width: 1100px) {
.content {
padding: 0 40px;
}
}
#media (max-width: 900px) {
.content {
padding: 0 30px;
}
}
#media (max-width: 868px) {
body.disabled {
overflow: hidden;
}
.icon {
display: block;
}
.icon.hide {
display: none;
}
.navbar .menu-list {
position: fixed;
height: 100vh;
width: 100%;
max-width: 400px;
left: -100%;
top: 0px;
display: block;
padding: 40px 0;
text-align: center;
background: #222;
transition: all 0.3s ease;
}
.navbar.show .menu-list {
left: 0%;
}
.navbar .menu-list li {
margin-top: 45px;
}
.navbar .menu-list li a {
font-size: 23px;
margin-left: -100%;
transition: 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.navbar.show .menu-list li a {
margin-left: 0px;
}
}
#media (max-width: 380px) {
.navbar .logo a {
font-size: 27px;
}
}
.cta {
padding: 9px 25px;
background-color: rgba(0, 136, 169, 1);
border: none;
border-radius: 50px;
cursor: pointer;
transition: background-color 0.3s ease 0s;
}
.cta:hover {
background-color: rgba(0, 136, 169, 0.8);
}
/* Nav end*/
<nav class="navbar">
<div class="content">
<div class="logo">
<img src="images/logo-villa-dor.jpg" width="100%">
</div>
<ul class="menu-list">
<div class="icon cancel-btn">
<i class="fas fa-times"></i>
</div>
<li>Fireplaces</li>
<li>Floorings</li>
<li>IronWorks</li>
<li>Ornaments</li>
<li>Woodwork</li>
<li>Radiators</li>
<li>Luminary</li>
<li>Miscellaneous</li>
</ul>
<div class="icon menu-btn">
<i class="fas fa-bars"></i>
</div>
</div>
</nav>
I think you're using #media wrong.
#media (max-width: 868px)
indicates that these styles will be applied when it has a max width of 868px. So for small screens you need to decrease the font-size in there.
#media (max-width: 868px) {
.navbar .menu-list li a{
font-size: 16px; // for example
margin-left: -100%;
transition: 0.6s cubic-bezier(0.68, -0.55, 0.265,
1.55);
}
}
I see some issues in your styles that have proven to be problematic for your design. For sake of demonstrating the media-queries behavior, I have deleted all your media queries and made just one that points to your <ul> and your logo, which appears to be the focal point in this example.
Please see the CSS changes I made between /* Media Start & /* Media End */. Also, my suggestion, if you are flexing the navbar, would be to use display: flex; instead of inline-flex. Then you can add justify-content: space-between; to properly align your nav components. Next, this is just out of preference, but I wouldn't suggest spacing your li's with margin-left because then you get left margin on your "Fireplaces" <li> which is just unnecessary margin. I used gap: 10px; as an alternative.
Please see the changes to the logo as well. With this correct structure for your media-queries, I believe it will be much easier for you to manipulate. Without being able to see your image or the size of it, it's challenging to give you an exact height & width so adjust the 25px around as necessary. Finally, setting font-sizes on logos or images won't be useful, unless there is a text element within the containing parent div of the image or logo.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
/* custom scroll bar */
::-webkit-scrollbar {
width: 10px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
background: #888;
}
::selection{
background: rgb(0,123,255,0.3);
}
.content{
max-width: 1250px;
margin: auto;
padding: 0 30px;
}
/* Nav start*/
.navbar{
position: fixed;
width: 100%;
z-index: 2;
padding: 25px 0;
transition: all 0.3s ease;
background-color: black;
}
.navbar.sticky{
background: black;
padding: 10px 0;
box-shadow: 0px 3px 5px 0px rgba(0,0,0,0.1);
}
.navbar .content{
display: flex;
align-items: center;
justify-content: space-between;
}
.navbar .logo a{
color: #fff;
font-size: 30px;
font-weight: 600;
text-decoration: none;
}
.navbar .menu-list{
display: flex;
justify-content: space-between;
gap: 10px;
}
.menu-list li{
list-style: none;
}
.menu-list li a{
color: #fff;
font-size: 18px;
font-weight: 500;
text-decoration: none;
transition: all 0.3s ease;
}
.menu-list li a:hover{
color: #007bff;
}
.banner{
height: 100vh;
background-position: center;
background-attachment: fixed;
}
.about{
padding: 30px 0;
}
.about .title{
font-size: 38px;
font-weight: 700;
}
.about p{
padding-top: 20px;
text-align: justify;
}
.icon{
color: #fff;
font-size: 20px;
cursor: pointer;
display: none;
}
.menu-list .cancel-btn{
position: absolute;
right: 30px;
top: 20px;
}
.cta {
padding: 9px 25px;
background-color: rgba(0, 136, 169, 1);
border: none;
border-radius: 50px;
cursor: pointer;
transition: background-color 0.3s ease 0s;
}
.cta:hover {
background-color: rgba(0, 136, 169, 0.8);
}
/* Nav end*/
/* Media Start */
#media only screen and (max-width: 800px) {
ul.menu-list li a {
font-size: 10px;
}
.logo {
width: 25px;
height: 25px;
}
}
/* Media End */
<nav class="navbar">
<div class="content">
<div class="logo">
</div>
<ul class="menu-list">
<div class="icon cancel-btn">
<i class="fas fa-times"></i>
</div>
<li>Fireplaces</li>
<li>Floorings</li>
<li>IronWorks</li>
<li>Ornaments</li>
<li>Woodwork</li>
<li>Radiators</li>
<li>Luminary</li>
<li>Miscellaneous</li>
</ul>
<div class="icon menu-btn">
<i class="fas fa-bars"></i>
</div>
</div>
</nav>
EDIT:
.navbar .content {
display: flex;
align-items: baseline;
justify-content: space-between;
align-content: center;
}
Then I would add two media queries like so :
#media only screen and (max-width: 1060px) {
.menu-list li a {
font-size: 13px;
}
}
#media only screen and (max-width: 945px) {
.menu-list li a {
font-size: 11.5px;
}
}

Why is the Flex text overlapping when Browser size is reduced?

If you reduce browser size, the text of "Discover" and "How it Works" overlap so that it looks like it says "Discover it works" "How".
How do I make it so that instead, the text of these Li items always stay separated? I tried doing flex: nowrap property but it had no effect.
Here is the codepen to show what I mean: https://codepen.io/hiarooo/pen/GRrzapM
Thanks for any help.
HTML
<header>
<div class="container">
<nav>
<div class="left-content">
<div class="header-user">
<img src="HOME/DoLogo.png" alt="logo" width="50px">
<p><span>Do</span></p>
</div>
<div class="header-tablet">
<div class="vl"></div>
<ul>
<li>Discover</li>
<li>How it works</li>
</ul>
</div>
</div>
<div class="right-content">
<div class="search">
<input type="text" placeholder="Search">
<i class="fas fa-search"></i>
</div>
<img id="notifications" src="HOME/Notification.svg" alt="Notification">
<div class="header-user">
<img src="HOME/uploadnav.png" alt="user">
</div>
<img class="mob" src="HOME/uploadnav.png" alt="user">
<img src="HOME/menu.svg" alt="hamburgermenu">
</div>
</nav>
</div>
</header>
CSS:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.container {
width: 78%;
margin: 0 auto;
}
#media (max-width: 1330px) {
.container {
width: 90%;
margin: 0 auto;
}
}
/* Header */
header {
height: 80px;
border: 1px solid #e6e8ec;
}
nav {
display: flex;
flex-direction: row;
justify-content: space-between;
}
#notifications{
padding-right:20px;
}
.search {
display: inline;
height: 40px;
width: 256px;
border-radius: 8px;
padding: 10px 12px 10px 16px;
border: 2px solid #e6e8ec;
outline: none;
display: flex;
justify-content: space-between;
margin-right: 18px;
margin-left: 20px;
}
.search input {
outline: none;
border: none;
}
.search i {
color: #777e90;
}
.search:hover {
cursor: pointer;
}
.search input::-webkit-input-placeholder {
font-family: "Poppins", sans-serif;
color: #777e90;
font-size: 12px;
}
.button {
background-color: #3772ff;
padding: 12px 16px;
border-radius: 90px;
font-family: "DM Sans", sans-serif;
font-weight: 700;
font-size: 14px;
line-height: 16px;
text-align: center;
color: #fcfcfd;
text-decoration: none;
margin-left: 18px;
margin-right: 10px;
display: inline;
}
.header-user {
border-radius: 90px;
padding: 4px 12px 4px 4px;
border: 2px #e6e8ec solid;
width: 147px;
height: 40px;
display: flex;
justify-content: center;
align-items: center;
}
.header-user p {
padding-left: 6px;
display: inline-block;
font-family: "DM Sans", sans-serif;
font-weight: 700;
font-size: 14px;
line-height: 16px;
}
.header-user span {
color: #45b26b;
padding-left: 2px;
}
.left-content {
display: flex;
height: 80px;
justify-content: center;
align-items: center;
}
.mob {
display: none;
}
.vl {
border-left: 2px #e6e8ec solid;
height: 40px;
margin: 0 32px;
}
.left-content ul {
list-style: none;
}
.left-content ul li {
display: inline;
}
.left-content ul li a {
text-decoration: none;
padding-right: 32px;
font-family: "DM Sans", sans-serif;
font-weight: 700;
font-size: 14px;
line-height: 16px;
color: #777e90;
}
.right-content {
display: flex;
height: 80px;
justify-content: center;
align-items: center;
}
.right-content img {
cursor: pointer;
}
.menu {
display: none;
}
.header-tablet {
display: flex;
justify-content: space-between;
height: 80px;
align-items: center;
}
.topFont{
font-size: 14px;
font-family: "DM Sans", sans-serif;
font-weight: 700;
text-decoration: none;
color: #23262f;
}
.btn-1 {
font-size: 14px;
font-family: "DM Sans", sans-serif;
font-weight: 700;
text-decoration: none;
color: #23262f;
border: 2px solid #e6e8ec;
border-radius: 90px;
display: inline-block;
padding: 12px 16px;
margin-bottom: 0px;
}
.btn-1:hover {
background-color: #3772ff;
color: #fcfcfd;
/*border: none;*/
transition:all .2s ease;
-webkit-transition-delay:all .2s ease;
-moz-transition-delay:all .2s ease;
-ms-transition-delay:all .2s ease;
-o-transition-delay:all .2s ease;
}
/* input */
.round {
max-width: 100%;
height: 48px;
background-color: #fff;
display: flex;
justify-content: space-between;
align-items: center;
border: 3px #f4f4f4 solid;
border-radius: 90px;
margin: 20px 0px;
}
.round i {
color: rgba(0, 0, 0, 0.3);
padding: 10px;
line-height: 80px;
}
.round input {
outline: none;
border: none;
padding-left: 16px;
}
.search-btn {
margin-top: 0px;
margin-bottom: 0px;
padding-left: 12px;
}
.round input::-webkit-input-placeholder {
font-family: "Poppins", sans-serif;
color: #777e90;
font-size: 12px;
}
.search-icon:hover {
cursor: pointer;
color: #3772ff;
}
#media (max-width: 1170px) {
.round {
width: 200px;
}
}
#media (max-width: 960px) {
.round {
width: 200px;
}
}
#media (max-width: 779px) {
.container {
width: 90%;
margin: 0 auto;
}
.header-tablet{
display:none;
}
.search {
display: none;
}
.menu {
display: inline;
}
.button {
display: none;
}
/* header user */
.header-user {
display: none;
}
Change this CSS setting:
.left-content ul li {
display: inline;
}
to
.left-content ul li {
display: inline-block;
}
That way the contents of that li element will form a (inline) block that can only wrap to a new line as a whole.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.container {
width: 78%;
margin: 0 auto;
}
#media (max-width: 1330px) {
.container {
width: 90%;
margin: 0 auto;
}
}
/* Header */
header {
height: 80px;
border: 1px solid #e6e8ec;
}
nav {
display: flex;
flex-direction: row;
justify-content: space-between;
}
#notifications {
padding-right: 20px;
}
.search {
display: inline;
height: 40px;
width: 256px;
border-radius: 8px;
padding: 10px 12px 10px 16px;
border: 2px solid #e6e8ec;
outline: none;
display: flex;
justify-content: space-between;
margin-right: 18px;
margin-left: 20px;
}
.search input {
outline: none;
border: none;
}
.search i {
color: #777e90;
}
.search:hover {
cursor: pointer;
}
.search input::-webkit-input-placeholder {
font-family: "Poppins", sans-serif;
color: #777e90;
font-size: 12px;
}
.button {
background-color: #3772ff;
padding: 12px 16px;
border-radius: 90px;
font-family: "DM Sans", sans-serif;
font-weight: 700;
font-size: 14px;
line-height: 16px;
text-align: center;
color: #fcfcfd;
text-decoration: none;
margin-left: 18px;
margin-right: 10px;
display: inline;
}
.header-user {
border-radius: 90px;
padding: 4px 12px 4px 4px;
border: 2px #e6e8ec solid;
width: 147px;
height: 40px;
display: flex;
justify-content: center;
align-items: center;
}
.header-user p {
padding-left: 6px;
display: inline-block;
font-family: "DM Sans", sans-serif;
font-weight: 700;
font-size: 14px;
line-height: 16px;
}
.header-user span {
color: #45b26b;
padding-left: 2px;
}
.left-content {
display: flex;
height: 80px;
justify-content: center;
align-items: center;
}
.mob {
display: none;
}
.vl {
border-left: 2px #e6e8ec solid;
height: 40px;
margin: 0 32px;
}
.left-content ul {
list-style: none;
}
.left-content ul li {
display: inline-block;
}
.left-content ul li a {
text-decoration: none;
padding-right: 32px;
font-family: "DM Sans", sans-serif;
font-weight: 700;
font-size: 14px;
line-height: 16px;
color: #777e90;
}
.right-content {
display: flex;
height: 80px;
justify-content: center;
align-items: center;
}
.right-content img {
cursor: pointer;
}
.menu {
display: none;
}
.header-tablet {
display: flex;
justify-content: space-between;
height: 80px;
align-items: center;
}
.topFont {
font-size: 14px;
font-family: "DM Sans", sans-serif;
font-weight: 700;
text-decoration: none;
color: #23262f;
}
.btn-1 {
font-size: 14px;
font-family: "DM Sans", sans-serif;
font-weight: 700;
text-decoration: none;
color: #23262f;
border: 2px solid #e6e8ec;
border-radius: 90px;
display: inline-block;
padding: 12px 16px;
margin-bottom: 0px;
}
.btn-1:hover {
background-color: #3772ff;
color: #fcfcfd;
/*border: none;*/
transition: all .2s ease;
-webkit-transition-delay: all .2s ease;
-moz-transition-delay: all .2s ease;
-ms-transition-delay: all .2s ease;
-o-transition-delay: all .2s ease;
}
/* input */
.round {
max-width: 100%;
height: 48px;
background-color: #fff;
display: flex;
justify-content: space-between;
align-items: center;
border: 3px #f4f4f4 solid;
border-radius: 90px;
margin: 20px 0px;
}
.round i {
color: rgba(0, 0, 0, 0.3);
padding: 10px;
line-height: 80px;
}
.round input {
outline: none;
border: none;
padding-left: 16px;
}
.search-btn {
margin-top: 0px;
margin-bottom: 0px;
padding-left: 12px;
}
.round input::-webkit-input-placeholder {
font-family: "Poppins", sans-serif;
color: #777e90;
font-size: 12px;
}
.search-icon:hover {
cursor: pointer;
color: #3772ff;
}
#media (max-width: 1170px) {
.round {
width: 200px;
}
}
#media (max-width: 960px) {
.round {
width: 200px;
}
}
#media (max-width: 779px) {
.container {
width: 90%;
margin: 0 auto;
}
.header-tablet {
display: none;
}
.search {
display: none;
}
.menu {
display: inline;
}
.button {
display: none;
}
/* header user */
.header-user {
display: none;
}
<header>
<div class="container">
<nav>
<div class="left-content">
<div class="header-user">
<img src="HOME/DoLogo.png" alt="logo" width="50px">
<p><span>Do</span></p>
</div>
<div class="header-tablet">
<div class="vl"></div>
<ul>
<li>Discover</li>
<li>How it works</li>
</ul>
</div>
</div>
<div class="right-content">
<div class="search">
<input type="text" placeholder="Search">
<i class="fas fa-search"></i>
</div>
<img id="notifications" src="HOME/Notification.svg" alt="Notification">
<div class="header-user">
<img src="HOME/uploadnav.png" alt="user">
</div>
<img class="mob" src="HOME/uploadnav.png" alt="user">
<img src="HOME/menu.svg" alt="hamburgermenu">
</div>
</nav>
</div>
</header>