gpt4 book ai didi

css - 如何将网站的位置设置在窗口的中间/中心?

转载 作者:行者123 更新时间:2023-11-28 13:40:09 24 4
gpt4 key购买 nike

* {
margin:0;
padding:0;
}

/** General Style Info **/
body {
background: #003d4c;
color: #fff;
font-family:'lucida grande',verdana,helvetica,arial,sans-serif;
font-size:90%;
margin: 0;
}
#container {
text-align: left;
}

#content {
background: #ffffff;
clear: both;
color: #333;
padding: 10px 10px 10px 10px;
margin-left: 1%;
margin-right: 1%;
margin-bottom: 5px;
overflow: auto;
width: 970px;
}

内容部门在容器部门内部。

该网站是用CRT显示器制作的,但是当我在高分辨率液晶显示器上浏览这个网站时,我发现网站右侧有更多空间。

内容或网站未设置在窗口中间。

如何将它设置在窗口的中间,使左右两侧离窗口的距离相等。

最佳答案

这是我一直做的方式:

body
{
text-align: centre;
//...
}

#container
{
margin: 0 auto;
text-align: left; // resets alignment for rest of site
width: 970px; // or whatever it needs to be
//...
}

它适用于大多数分辨率(在 1024x768、1360x768、1920x1080 上测试,从未听说过使用不同分辨率的人出现问题)。

关于css - 如何将网站的位置设置在窗口的中间/中心?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8014124/

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