htmlcssdisplayjustify

How can i resolve a problem of display: flex on html & css?


Hellow friends, could somebody help me, i'm very noob in html, this is my first code, i'm watching a youtube video to learn, but i have issues with this, i want to do that is on the video, and is not working this is the code in html

<!DOCTYPE html>
<html lang = "es">
    <head>
        <meta charset="UTF-8">
        <title>Tienda Online</title>
        <meta name="viewport" content="width-device-width, user-scalable-no, initial-scale=1.0, maximun-scale=1.0, minimun-scale=1.0">
        <link rel="stylesheet" href="css/estilos.css">
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css">
    </head>
    <body>
        <header class="main-header">
            <div clas="container container--flex">
                <div clas="main-header__container">
                    <h1 class="main-header__title">GOGGLES</h1>
                    <span class="icon-menu fa-solid fa-bars" id="btn-menu"></span>
                    <nav class="main-nav" id="main-nav">
                        <ul class="menu">
                            <li class="menu__item"><a href="" class="menu__link">HOME</a></li>
                            <li class="menu__item"><a href="" class="menu__link">ABOUT</a></li>
                            <li class="menu__item"><a href="" class="menu__link">FEATURES</a></li>
                            <li class="menu__item"><a href="" class="menu__link">SHOP</a></li>
                            <li class="menu__item"><a href="" class="menu__link">CONTACT</a></li>
                        </ul>
                    </nav>
                </div>
                <div clas="main-header__container">
                    <span class="main-header__txt">Need Help</span>
                    <p class="main-header__txt"><i class="fa-solid fa-phone"></i> Call 12345678099</p>
                </div>   
                <div clas="main-header__container">
                <i class="fa-solid fa-user"></i>
                <a href="">My cart<i class="fa-solid fa-cart-shopping"></i></a>
                <input type="search"><i class="fa-solid fa-magnifying-glass"></i>
                </div> 
            </div>
        </header>
    </body>
</html>

an this is in css:

* {
  box-sizing: border-box;
}
body{
  margin :0;
}
img{
  display: block;
  width: 100%;
}
.main-header__title{
  text-align: center;
  font-size: 2.5em;
  margin: 10px 0px;
  color: #454546;
}
.main-nav{
  display: none;
}
.main-header__title{
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.icon-menu{
  font-size: 1.5em;
  border: 1px solid #454546;
  display: block;
  padding: 10px 20px;
}

its supposed to watch like this

But, it looks like this

maybe its a problem on the display:flex or in the justify-content: space around. My real problem is that i don't know how to change this

thanks ;D


Solution

  • Errors were:

    1. Typos in word "clas"
    2. Use wrong class in CSS - ".main-header__title" instead of ".main-header__container"

    Here is a solution:

    * {
      box-sizing: border-box;
    }
    
    body {
      margin: 0;
    }
    
    img {
      display: block;
      width: 100%;
    }
    
    .main-header__title {
      text-align: center;
      font-size: 2.5em;
      margin: 10px 0px;
      color: #454546;
    }
    
    .main-nav {
      display: none;
    }
    
    .main-header__container {
      display: flex;
      justify-content: space-around;
      align-items: center;
    }
    
    .icon-menu {
      font-size: 1.5em;
      border: 1px solid #454546;
      display: block;
      padding: 10px 20px;
    }
    <!DOCTYPE html>
    <html lang="es">
    
    <head>
      <meta charset="UTF-8">
      <title>Tienda Online</title>
      <meta name="viewport" content="width-device-width, user-scalable-no, initial-scale=1.0, maximun-scale=1.0, minimun-scale=1.0">
      <link rel="stylesheet" href="css/estilos.css">
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css">
    </head>
    
    <body>
      <header class="main-header">
        <div class="container container--flex">
          <div class="main-header__container">
            <h1 class="main-header__title">GOGGLES</h1>
            <span class="icon-menu fa-solid fa-bars" id="btn-menu"></span>
            <nav class="main-nav" id="main-nav">
              <ul class="menu">
                <li class="menu__item"><a href="" class="menu__link">HOME</a></li>
                <li class="menu__item"><a href="" class="menu__link">ABOUT</a></li>
                <li class="menu__item"><a href="" class="menu__link">FEATURES</a></li>
                <li class="menu__item"><a href="" class="menu__link">SHOP</a></li>
                <li class="menu__item"><a href="" class="menu__link">CONTACT</a></li>
              </ul>
            </nav>
          </div>
          <div class="main-header__container">
            <span class="main-header__txt">Need Help</span>
            <p class="main-header__txt"><i class="fa-solid fa-phone"></i> Call 12345678099</p>
          </div>
          <div class="main-header__container">
            <i class="fa-solid fa-user"></i>
            <a href="">My cart<i class="fa-solid fa-cart-shopping"></i></a>
            <input type="search"><i class="fa-solid fa-magnifying-glass"></i>
          </div>
        </div>
      </header>
    </body>
    
    </html>