2015-06-23 60 views
2

我正在開發由3張圖片組成的背景的asp.net webforms;頂部,左側和右側。從完整的圖像裁剪3件,以適應中間770px寬度的內容體。目前,當我向下滾動或向上滾動時,這3幅圖像會隨着內容的變化而移動。當我滾動頁面時,我希望背景保持靜止。我用純HTML的代碼,其適用於單個完整背景圖片:我希望我的背景3件在asp.net中是靜止的

<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

我會使用一個單獨的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> 
+0

謝謝。有用。 – matt2605

+0

哥們沒問題:) –

相關問題