英文:
How can i resolve a problem of display: flex on html & css?
问题
你好朋友,能有人帮助我吗,我对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, maximum-scale=1.0, minimum-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>
这是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;
}
应该看起来像这样:链接,但实际上看起来像这样:链接。也许问题出在display: flex
或justify-content: space-around
。我真正的问题是我不知道如何更改这些。谢谢;D
英文:
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
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
答案1
得分: 0
错误如下:
- 单词 "clas" 中的拼写错误。
- 在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, maximum-scale=1.0, minimum-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>
英文:
Errors were:
- Typos in word "clas"
- Use wrong class in CSS - ".main-header__title" instead of ".main-header__container"
Here is a solution:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-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__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;
}
<!-- language: lang-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 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>
<!-- end snippet -->
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论