0

i have the following code

header {
  width: 100%;
  height: 65px;
  background: #fff;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #252c3a;
}

#menu {
  width: 100%;
  display: flex;
  margin-left: 28%;
}

#menu div {
  width: 100px;
  height: 65px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
<header>
  <div id="logo">
      <img src="img/header/logo.png" alt="Logo">
  </div>
  <div id="menu">
      <div>Home</div>
      <div>Club-Life</div>
      <div>Training</div>
      <div>Instructors</div>
      <div>Contact</div>
  </div>

Chrome inspect

The width of the other blocks is 100%, but the header width gets bigger than the block below. I use justify-content: space-between.

Mister Jojo
  • 20,093
  • 6
  • 21
  • 40
R0b001
  • 3
  • 1

3 Answers3

1

Remove width & margin

Add flex-wrap on the header

header {
    width: 100%;
    height: 65px;
    background: #fff;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #252c3a;
    flex-wrap:wrap;
}

#menu {
    display: flex;
    flex-wrap:wrap;
}
Lalji Tadhani
  • 14,041
  • 3
  • 23
  • 40
0

There are few things we need to do:

In header:

1. Remove width

In #main:

1. Remove width
2. Remove margin

In #menu div:

1. Remove everything and just add margin left

Demo: https://codepen.io/Bibeva/pen/povddJr

Final code:

header {
    height: 65px;
    background: #fff;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #252c3a;
}

#menu {
    display: flex;
}

#menu div {
    margin: 0 0 0 30px;
}
Bibek Shakya
  • 151
  • 2
-1

#menu {
    display: flex;
}

that's all , Can you try this ?

fdurna
  • 318
  • 1
  • 7