gpt4 book ai didi

html - 为什么导航栏看起来像这样?

转载 作者:行者123 更新时间:2023-11-28 01:20:47 25 4
gpt4 key购买 nike

这就是问题所在:导航栏看起来像是在页面下方 float 。

the probleme image

为什么导航栏看起来像这样?我还是 css 的新手,我已经尝试了所有方法,但没有任何效果。我又重写了代码,但问题没有解决。导航应该如下所示。

<code>how it should look</code>

本教程来自这个udemy类(class) https://www.udemy.com/design-and-develop-a-killer-website-with-html5-and-css3/#%2F

* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

html,
body {
background-color: #fff;
color: #555;
font-family: 'Lato', 'Arial', sans-serif;
font-weight: 300;
font-size: 20px;%);
text-rendering: optimizeLegibility;
overflow-x: hidden;
}


/*-------------------------------------------------*/
/*reusable componment*/
/*-------------------------------------------------*/%);
.row {
max-width: 1140px;
margin: 0 auto;
}


/*-----------*/
/*headings*/
/*-----------*/
h1 {
margin: 0;
margin-bottom: 20px;
margin-top: 0;
color: #fff;
font-size: 240%;
font-weight: 300;
text-transform: uppercase;
letter-spacing: 1px;
word-spacing: 4px;
}

/*-----------*/
/*buttons*/
/*-----------*/
.btn:link,
.btn:visited {
display: inline-block;
padding: 10px 30px;
font-weight: 300;
text-decoration: none;
border-radius: 200px;
transition: background-color 0.2s,border 0.2s ,color 0.2s;
}
.btn-1:link,
.btn-1:visited {
background-color: #e67e22;
color: #fff;
margin-right: 15px;
}

.btn-2:link,
.btn-2:visited {
border: 1px solid #e67e22;
color: #e67e22

}
.btn-1:hover,
.btn-1:active {
background-color: #b05d14;

}
.btn-2:hover,
.btn-2:active {
background-color: #b05d14;
color: #fff;
}
/*-------------------------------------------------*/
/*HEADER*/
/*-------------------------------------------------*/
.hero-text-box{
position: absolute;
width: 1140px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);

}
header {
background-image: -webkit%);-linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url(assets/images/hero.jpg);
background-size: cover;
background-position: center;
height: 100vh;
background-attachment: fixed;
}


.logo{
height: 100px;
width: auto;
float: left;
margin-top: 20px;
}
.main-nav {

float: right;
list-style: none;
margin-top: 55px;

}

.main-nav li {

display: inline-block;
margin-left: 40px;
}

.main-nav li a:link,
.main-nav li a:visited {
padding: 8px 0;
color: #fff;
text-decoration: none;
text-transform: uppercase;
font-size: 90%;
border-bottom: 2px solid transparent;
-webkit-transition: border-bottom 0.3s, color 0.3s;
transition: border-bottom 0.3s, color 0.3s;
}

.main-nav li a:hover,
.main-nav li a:active {
border-bottom: 2px solid #BF55EC;
<!DOCTYPE html>
<html>
<head>
<title>omni food</title>
<link rel="stylesheet" type="text/css" href="normalize.css">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" type="text/css" href="grid.css">
<link href="https://fonts.googleapis.com/css?family=Lato:100,300,300i,400" rel="stylesheet">


</head>
<body>
<header>
<nav>
<div class="row">
<img src="assets/images/logo-white.png" alt="omni-food" class="logo">

</div>

<div class="main-nav">
<ul>
<li> <a href="#">Food delivery</a> </li>
<li> <a href="#">How it works</a> </li>
<li> <a href="#">Our cities</a> </li>
<li> <a href="#">Sign up</a> </li>

</ul>

</div>

</nav>
<div class="hero-text-box">
<h1>Goodbye junk food.<br>hello super healthy meals</h1>
<a class="btn btn-1" href="#">I'm hungry</a>
<a class="btn btn-2" href="#">show me more</a>
</div>
</header>
</body>
</html>

请帮帮我

最佳答案

The 被定义为占据屏幕上的整行。这会强制进入一个新行,使其看起来更低。如果您仍然想要行类的功能,它应该同时包含 img 和 UL。您可以完全摆脱那个 div,并将类行应用到 Nav 元素。

    <nav class="row">
<img src="assets/images/logo-white.png" alt="omni-food" class="logo">
<div class="main-nav">
<ul>
<li> <a href="#">Food delivery</a> </li>
<li> <a href="#">How it works</a> </li>
<li> <a href="#">Our cities</a> </li>
<li> <a href="#">Sign up</a> </li>

</ul>

</div>

</nav>

关于html - 为什么导航栏看起来像这样?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51507078/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com