代码之家  ›  专栏  ›  技术社区  ›  Jitendra Vyas

46px空间后如何开始背景重复?

  •  1
  • Jitendra Vyas  · 技术社区  · 15 年前
    #data-wrapper {
    background:url("../images/repeat-bg.png") repeat-y 0 46px transparent;}
    

    我想开始 repeat-bg.png 作为一个 repeat-y 但之后 46px 从顶部开始的区域 #data-wrapper . 可以这样做吗?

    2 回复  |  直到 11 年前
        1
  •  1
  •   Moses    15 年前

    您需要将背景图像应用到包含46px边距的DIV。

    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <style type="text/css">
    #container {
    background:url("../images/repeat-bg.png") repeat-y; margin-top:46px; height:600px;}
    /* height:600px is only critical to the demo code and can be removed once the page has content */
    </style>
    </head>
    <body>
    <div id="container">
    <!--All of your content goes here-->
    </div>
    </body>
    </html>
    

    除此之外,如果对这一方法的支持不是关键的,您可以向前思考并采用当前的 非常 在支持的CSS3下,多个后台声明。

    body {background:url("bg1.png") top no-repeat, url("bg2.png") bottom repeat-y;}
    
        2
  •  4
  •   Pekka    15 年前

    你是说前46个像素没有背景图像?

    不,那是不可能的,对不起。你必须解决它,例如使用另一个 div 有余地。