到目前为止,我已经设法使背景图像伸展:背景图像拉伸和作物
XHTML:
<div id="background">
<img src="images/background.jpg" alt="Background" />
</div>
CSS:
#background
{
width: 100%;
height: auto;
position: fixed;
left: 0px;
top: 0px;
}
#background img
{
width: 100%;
height: 100%;
}
这种运作良好,除了图像当图像的高度超过窗口高度时,从顶部显示。这意味着图像的顶部始终显示,但底部被切断。我想改变它,以便图像始终从中心显示(以便图像的顶部和底部都被切掉,并显示图像的中心)。
使用img作为身体的bakcground图像有什么问题? – Kyle 2012-04-03 12:28:42
我想你可能需要帮助jquery来实现这一点。 – Dips 2012-04-03 13:03:54