Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 为什么不是';这不是中心吗?(边距:0自动;不工作)_Html_Css_Margin - Fatal编程技术网

Html 为什么不是';这不是中心吗?(边距:0自动;不工作)

Html 为什么不是';这不是中心吗?(边距:0自动;不工作),html,css,margin,Html,Css,Margin,我目前正在制作一个网站(老实说,我不擅长编码),但我遇到了一个问题,我把我的内容划分为0自动,这应该把它放在中心吗?但它现在不起作用了 网站(查看问题): CSS: 非常感谢 -贝利在看到你的网站后,我看到了这个 body { min-width:900px; height: 100%; margin:0 auto; padding:0; background-color:#000; } 把它改成 body { width:900px;

我目前正在制作一个网站(老实说,我不擅长编码),但我遇到了一个问题,我把我的内容划分为0自动,这应该把它放在中心吗?但它现在不起作用了

网站(查看问题):

CSS:

非常感谢


-贝利

在看到你的网站后,我看到了这个

body {
    min-width:900px;    
    height: 100%;
    margin:0 auto;
    padding:0;
    background-color:#000;
}
把它改成

body {
    width:900px;    
    height: 100%;
    margin:0 auto;
    padding:0;
    background-color:#000;
}

由于此
页边距:0 auto;
不起作用,您没有给出宽度

为content div添加css

#content
{
  text-align: center;
}

这可能是您想要的:

#content {
    width: 900px; 
    margin: 0 auto;
}
如果希望宽度更灵活,可以将其更改为其他宽度,如%宽度


一般来说,最好不要在<>代码>正文>代码>元素本身设置宽度、最小宽度等。

这只是把整个站点压扁了,我只想要中间的内容。因此,给内容和余量赋予宽度:0自动;值它会工作。