0

半透明の div (ページの 100%、不透明度 0.6) に小さな白い div を表示しようとしています。

区分:

<div id="confirmDialogSingle" class="Loading" runat="server" visible="false">
<div id="msgBox" class="loadingImg">
<br /> You already have a request on the chosen date. Are you sure you want to submit this request?<br /><br />
<asp:Button ID="BtnConfirmSingle" runat="server" Text="Yes"  Width="60px" onclick="BtnConfirmSingle_Click" />&nbsp;
<asp:Button ID="BtnNo" runat="server" Text="Cancel" onclick="BtnNo_Click" />
</div>
</div>

CSS:

.Loading
{
    width: 100%; 
    height: 100%; 
    top:0;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;
    position: fixed;
    background: white;
    opacity:0.6;
    z-index:9999;
    transition: width 2s; -moz-transition: width 2s;/* Firefox 4 */ -webkit-transition: width 2s; /* Safari and Chrome */ -o-transition: width 2s; /* Opera */

}

.loadingImg
{
    opacity: 1;
    margin: auto;
    width: 700px;
    text-align: center;
    height: 150px;
    padding: 10px;
    background-color: white;
    border:1px solid #d9a0e2;
}

問題は、小さな div (.loadingImg) が画面の中央に表示されず (上 50% と左 50% も試しました)、その背景がまだ白ではなく透明に表示されていることです!

4

3 に答える 3

2

これを試して:

.Loading {
    position:fixed;
    width:100%; height:100%; 
    top:0; left:0;
    background: rgba(255,255,255,0.6);
    z-index:9999;
    transition: width 2s; -moz-transition: width 2s;/* Firefox 4 */ -webkit-transition: width 2s; /* Safari and Chrome */ -o-transition: width 2s; /* Opera */ }

.loadingImg {
    position: absolute;
    top: 50%; margin-top:-85px;
    left:50%; margin-left:-360px;
    width:700px; height:150px;
    opacity: 1;
    text-align: center;
    padding: 10px;
    background-color: #FFF;
    border: 1px solid #d9a0e2;
}

または、半透明の png 画像を .Loading div の背景画像として使用することもできます

于 2013-07-31T09:40:24.333 に答える
0

次のコードは、画面中央の 2 番目の div を取得するのに役立ちます。

<div id="confirmDialogSingle" class="Loading" runat="server" visible="false">
<table style="height:100%;" align="center">
<tr>
    <td>
        <div id="msgBox" class="loadingImg">
            <br /> You already have a request on the chosen date. Are you sure you want to submit this request?<br /><br />
            <asp:Button ID="BtnConfirmSingle" runat="server" Text="Yes"  Width="60px" onclick="BtnConfirmSingle_Click" />&nbsp;
            <asp:Button ID="BtnNo" runat="server" Text="Cancel" onclick="BtnNo_Click" />
        </div>
    </td>
    </tr>
</table>
</div>

不透明度の問題について。最初の div。実際の不透明度ではなく、背景色の不透明度を変更します。実際の不透明度は子コントロールにも影響するためです。

background: rgba(255,255,255,0.6);

opacity:1; を削除した後、上部の div に上記を追加します。

于 2013-07-31T09:54:56.803 に答える