我希望我的3个部分的背景在asp.net中是固定的

时间:2015-06-23 10:20:19

标签: html css asp.net

我正在开发asp.net webforms,其背景由3个图像组成;顶部,左侧和右侧。这3件作品从完整的图像裁剪,以适应中间770px宽度的内容。目前,当我向下或向上滚动时,这3个图像随着身体内容移动。当我滚动页面时,我希望背景保持静止。我在纯HTML中使用此代码,该代码适用于单个完整的背景图像:

    <head>
       <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
       <title>Layout Example</title>
       <link rel="stylesheet" type="text/css" href="./Layout Example_files/style.css">
       <style type="text/css">
          body{
            background:  url( "images/SoapBubbles.jpg" ) no-repeat fixed top center;
        }
       </style>
    </head>

如果整个背景只有一张图片,我怎么在asp.net中这样做呢?

1 个答案:

答案 0 :(得分:1)

我会使用一个单独的div并使用固定定位。实施例

<head>
   <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
   <title>Layout Example</title>
   <link rel="stylesheet" type="text/css" href="./Layout Example_files/style.css">
   <style type="text/css">
      .fixed-background{
        background:  url( "images/SoapBubbles.jpg" ) no-repeat fixed top center;
        position:fixed;
        z-index:-1;
        top:0;
        right:0;
        left:0;
        bottom:0;
    }
   </style>
</head>
<body>
   <div class="fixed-background"></div>
   <div class="content"></div>
</body>