gpt4 book ai didi

html - 一个元素不能居中,因为有些东西看起来不对

转载 作者:太空宇宙 更新时间:2023-11-03 21:28:16 24 4
gpt4 key购买 nike

我正在尝试制作一个网页,其中所有内容都位于中心 40%,但顶部标题似乎没有以水平导航栏为中心。看看左边的空间似乎比右边多,文本比导航栏长?

screen shot

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Sample test page</title>
<style>
#navigation li {
font 34px Arial;
display: inline-block;
list-style-type: none;

}

#navigation a {
background: #140913;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
display: inline-block;
cursor: pointer;
color: #ffffff;
font-size: 18px;
padding: 5px 19px;
text-decoration: none;
text-shadow: 0px 1px 0px #2f6627;
}

#navigation a:hover {
background: #4a3a4a;
text-decoration: none;
}





#text {
width: 90%;
margin: 0 auto;
text-align: left;
}

#background {
background-size: 100% auto;
}

.stretch {
width:100%;
height:100%;
}

body {
margin-top: auto;
margin-right: auto;
margin-left: auto;
margin-bottom: auto;
text-align: center;
width: 50%

}

footer {
margin: auto;
text-align: center;
}


</style>
</head>

<body>
<nav>
<div id="navigation">
<ul>
<li><a href="#">AAAAAAA</a></li>
<li><a href="#">BBBBB</a></li>
<li><a href="#">CCCCCCC</a></li>
<li><a href="#">DDDDDDD</a></li>
<li><a href="#">EEEEEEE</a></li>
<li><a href="#">FFFFF</a></li>
<li><a href="#">GGGGGGG</a></li>
</ul>
</div>
</nav>
<div id="background"> <br />
</div>
<div id="wordcloud">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit quisque malesuada erat sed sagittis gravida<br /> suspendisse in sem sed magna ultrices.</p>
</div>
<div id="wordclouddescription">
<h2>The sentence will be aproximitely the same size here as on the final product, thankyou very much.</h2>
<p>&nbsp;</p>
<div id="text"> </div>
</div>
</body>
</html>

最佳答案

我想你必须重新设置你的 ul,它仍然有 40px 的填充。

#navigation ul {
padding: 0;
margin: 0;
}

关于html - 一个元素不能居中,因为有些东西看起来不对,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31239146/

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