如何解决显示问题:HTML和CSS上的Flex?

wwwo4jvm  于 2023-02-10  发布在  其他
关注(0)|答案(1)|浏览(149)

大家好,朋友们,有人能帮我吗,我是非常noob在html,这是我的第一个代码,我看了youtube视频学习,但我有这个问题,我想这样做是在视频中,是不是工作这是在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>

这是在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
可能是显示器上的问题:flex或调整内容:我真实的的问题是我不知道如何去改变它
谢谢

ioekq8ef

ioekq8ef1#

错误为:
1.单词“class”中的拼写错误
1.在CSS中使用错误的类-“.main-header__title”而不是“.main-header__container”
下面是一个解决方案:

* {
  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>

相关问题