2014-09-02 43 views
1

你好朋友我有一個代碼顯示處理圖像,但我不知道背景會改變它的顏色,我需要將它改爲灰色。設置一個灰色的透明背景

<body> 
<form id="form1" runat="server"> 
<div> 
    <asp:ScriptManager ID="ScriptManager1" runat="server"> 
    </asp:ScriptManager> 
    <script type="text/javascript"> 
     // Get the instance of PageRequestManager. 
     var prm = Sys.WebForms.PageRequestManager.getInstance(); 
     // Add initializeRequest and endRequest 
     prm.add_initializeRequest(prm_InitializeRequest); 
     prm.add_endRequest(prm_EndRequest); 

     // Called when async postback begins 
     function prm_InitializeRequest(sender, args) { 
      // get the divImage and set it to visible 
      var panelProg = $get('divImage'); 
      panelProg.style.display = ''; 
      // reset label text 
      var lbl = $get('<%= this.lblText.ClientID %>'); 
      lbl.innerHTML = ''; 

      // Disable button that caused a postback 
      $get(args._postBackElement.id).disabled = true; 
     } 

     // Called when async postback ends 
     function prm_EndRequest(sender, args) { 
      // get the divImage and hide it again 
      var panelProg = $get('divImage'); 
      panelProg.style.display = 'none'; 

      // Enable button that caused a postback 
      $get(sender._postBackSettings.sourceElement.id).disabled = false; 
     } 
    </script> 

    <asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
     <ContentTemplate> 
      <asp:Label ID="lblText" runat="server" Text=""></asp:Label> 
      <div id="divImage" style="display:none" class="divCentro"> 
       <div class="FondoGris"> 
        <asp:Image ID="img1" runat="server" ImageUrl="~/Procesando2.gif"/> 
        </div> 
       <br /> 
       <p class="divCentro"><br /><br /><br />Processing...</p> 
      </div>     
      <br /> 
      <asp:Button ID="btnInvoke" runat="server" Text="Click" 
       onclick="btnInvoke_Click" /> 
     </ContentTemplate> 
    </asp:UpdatePanel> 
</div> 
</form> 

這裏是CSS代碼:

<style type="text/css"> 
    .divCentro { 
     text-align:center; 
     width: 327px; height: 60px; margin-top: -23px; margin-left: -158px; left: 50%; top: 40%; position: absolute; 
    } 

</style> 

我試着寫背景顏色:灰色透明,但這隻能改變DIV圖像中的顏色。

如果有人有任何建議,請幫助我。

在此先感謝!

+0

設置bac kground顏色爲黑色,並將alpha值設置爲0.4或0.5 例如:'background-color:rgba(0,0,0,0.5);' – practice2perfect 2014-09-02 17:31:13

+0

'但這隻會改變div'中的顏色 - 你想改變呢? – LcSalazar 2014-09-02 17:34:20

回答

1

嘗試這一個..

<div class="divOuterCentro"> 
<p class="divCentro"><br /><br /><br />Processing...</p> 
</div> 

CSS:

.divOuterCentro{ 
    height:100%; 
    width:100%; 
    background-color:rgba(0,0,0,0.4); 
    position:absolute; 
} 
.divCentro { 
    text-align:center; 
    width: 327px; 
    height: 60px; 
    margin-top: -23px; 
    margin-left: -158px; 
    left: 50%; 
    top: 40%;  
    position: absolute; 
} 

工作小提琴.. link here

0

要創建半透明背景使用RGBA()或HSLA()函數:

.divCentro { 
    background-color: rgba(60, 60, 60, 0.5); 
}