gpt4 book ai didi

css - 如何制作平面设计菜单栏?

转载 作者:行者123 更新时间:2023-11-28 10:30:31 26 4
gpt4 key购买 nike

您好,我正在尝试制作一个网站,但我的菜单栏没有正常工作。它应该是这样的: http://i.stack.imgur.com/KDvwo.png

但它看起来像这样: http://i.stack.imgur.com/Y1Ya8.png

这是我的代码:

HTML

<div class="wrapper">
<header>
<h1>Colve</h1></div>
<nav>
<ul class="menu1">
<li><a class="button" href="#">Home</a></li>
<li><a class="button" href="#about">About</a></li>
<li><a class="button" href="#downloads">Downloads</a>
<li><a class="button" href="invasion.html">INVASION</a></li>
</li><li><a class="button" href="contact.html">Contact</a></li>
</ul>
</nav>
</header>
<section id="about">
<h1>About-Colve</h1>
<p>Colve is a company that gives you the things you want in one place</p>
<p>Created by Bradley Beeke</p>
</section>
</div>

CSS

html {
font:12pt Lato, sans-serif;
min-height:100%;
background-image:linear-gradient(45deg,#3498db,#2ecc71);
}
body{margin:0px;}

header{
background-color:white;
Color: #FFDF00;
float:left;
padding-left:5px;
display:block;


}
nav {
background-color:white;
float:right;
padding-right:5px;
height:60px;
display:block;
width:100%;
float:right;

}
nav a {
text-decoration:none;
list-style:none;
color:#FFDF00;
font-size:20px;
padding:8px;

}
nav li:hover, a:hover {color:#998100;}
li{display:inline;}
section { margin-bottom: 1000px; padding-top: 150px; float: left; }

请你帮帮我!

最佳答案

Working DEMO

<div class="wrapper">
<header>
<h1>Colve</h1> <!-- remove the </div> present here -->
<nav>
<ul class="menu1">
<li><a class="button" href="#">Home</a></li>
<li><a class="button" href="#about">About</a></li>
<li><a class="button" href="#downloads">Downloads</a>
<li><a class="button" href="invasion.html">INVASION</a></li>
</li><li><a class="button" href="contact.html">Contact</a></li>
</ul>
</nav>

在导航CSS中,将宽度设置为自动

nav {
background-color:white;
float:right;
padding-right:5px;
height:60px;
display:block;
width:auto;
float:right;
}

header {} 中添加 width: 100%; 因为当前标题没有正确对齐。HTML 没有很好地构造。请从代码中删除多余的 and。

关于css - 如何制作平面设计菜单栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23548286/

26 4 0