背景图像始终居中 [英] Background image always centered

查看:123
本文介绍了背景图像始终居中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个网站,但有一个问题,迫使背景图像始终处于中心位置。当站点最大化时它看起来很棒,但是当我使窗口分辨率更小时,背景被推到左边,内容溢出到右边。如果我可以强制背景图像始终居中,无论窗口大小如何,都可以解决。我的CSS居中图像看起来如下

I have created a website but am having an issue forcing the background image to always be center. It looks great when the site is maximized but when I make the window resolution smaller the background gets pushed to the left and the content overflows to the right. It would be solved if I could just force the background image to just be centered all the time no matter what the window size. My CSS to center the image looks as follows

    body {  background: #EDEDED url(../images/bg-y.png) repeat-y scroll 50% 0;
                font-size:12px; 
                font-family:'Lucida Grande', 'Lucida Sans Unicode', Tahoma, Arial, san-serif;
                color:#000000; }

我有一个可以在 http://www.theprizeshark.com/

为了得到我说的错误最小化窗口,所以你必须滚动到右侧,你会看到内容都溢出背景图像。谢谢。

To get the error I am talking about minimize the window so you have to scroll to the right and you will see that the content all overflows the background image. Thanks.

推荐答案

我认为您所需要做的就是改变百分比 50% center

I think all you need to do is change the percentage 50% to center

这篇关于背景图像始终居中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆