Css 流体布局背景100%宽,每侧填充50像素

Css 流体布局背景100%宽,每侧填充50像素,css,Css,好的,所以我需要添加一个背景图像来重复100%,但我需要在每一侧添加边距 ****************************************** * * * * * 50 * * 50 * * px * This background image should * px * * * repeat-x 100% minus 100px. *

好的,所以我需要添加一个背景图像来重复100%,但我需要在每一侧添加边距

******************************************
*    *                              *    *
* 50 *                              * 50 *
* px * This background image should * px *
*    * repeat-x 100% minus 100px.   *    *
*    *                              *    *
******************************************

我会在div中使用div。这样你可以将背景应用到第二个div,让第一个div担心边距

#div1 {
    margin: 0 50px;
}

#div2 {
    background: url('XXX') no-repeat;
    background-size: 100% 100%;
}
请注意:背景大小是CSS3属性,IE9+、Firefox 4+、Opera、Chrome和Safari 5+支持背景大小

或者使用:

#div {
    background: url('XXX') repeat-x;
    margin: 0 50px;
}

这不是一个好的做法,我不确定哪一个是最好的解决方案,这取决于你的背景是颜色/图案还是图像。如果不是图像,请使用后一种解决方案。

和@Victor?考虑添加一个jsFoDeld链接到什么地方,你被卡住了。谢谢!但是,我需要传统的支持到IE7。那么解决方案2,它是一个你正在使用的图像吗?我使用三个图像:一个在一个侧面,一个中间需要流体。