gpt4 book ai didi

css - 调整浏览器窗口大小时保持背景图像居中

转载 作者:行者123 更新时间:2023-12-02 07:42:32 26 4
gpt4 key购买 nike

因此,我正在为 SMF 论坛进行布局,并且当浏览器窗口足够宽时,背景图像会完美居中。但是,当我开始缩小浏览器窗口时,背景图像开始向左移动。这是我当前的背景 CSS:

body
{
background: #fefff1 url(../images/img/bg.gif) no-repeat;
background-position:top center;
margin: 0 auto;
color: #7C3C4A;
padding: 0px 5%;
font: 78%/130% "Verdana", "Arial", "Helvetica", sans-serif;
}

这是论坛的屏幕截图,以便您可以更好地对其进行可视化:

http://i.imgur.com/49pRI.png

最佳答案

body
{
background-color: #fefff1;
background-image: url(../images/img/bg.gif);
background-position: center center; /* First value is from left and second is from top. You can use use number as well*/
background-repeat:no-repeat;
}​

关于css - 调整浏览器窗口大小时保持背景图像居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9576924/

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