gpt4 book ai didi

css - 我无法让我的网站居中

转载 作者:太空宇宙 更新时间:2023-11-03 23:43:59 25 4
gpt4 key购买 nike

无论我做什么,我的网站都不会居中。我试过了

margin: auto 0;

我试过了

margin-left: 50%;
margin-right: 50%;

我取得的最大成功是让整个网站向右对齐,这并不是我想要的。

这是控制网站对齐方式以及其他细节的 CSS。如果您能帮助我,我将不胜感激。

#Content {
width: 1200px;
height: 850px;

padding: 5px;
margin-left: 50%;
margin-right: 50%;

background-color: #006600;

font-size: 12px;
font-color: #000;
text-align: center;
font-style: normal;
font-family: Arial, Helvetica, sans-serif;
}

最佳答案

安德鲁是对的,应该是:

margin:0 auto;

这是用速记格式表示边距。当只给出 2 个值时,它被解释为:

margin: (top and bottom value), (left and right value);

所以

margin: 1px 2px;

表示

margin-top: 1px;
margin-bottom: 1px;
margin-left: 2px;
margin-right: 2px;

更多信息 here

关于css - 我无法让我的网站居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22030890/

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