Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading