CSS實現彈窗遮罩層效果--position定位學習

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>css彈窗遮罩效果</title>
    </head>
    <style>
        .main{
            margin: 0 auto;
            width: 1024px;
            height: 1024px;
            background: url(img/background.png) repeat-y;
            position: relative;
            bottom: 30px;
            top: 30px;
        }
        .mask{
            width: 100%;
            height: 100%;
            opacity: .3;
            filter: alpha(opacity=30);
            background-color: #000;
            position: fixed;
            left: 0;
            top: 0;
        }
        .login{
            width: 300px;
            height: 300px;
            background: url(img/login.png) no-repeat;
            position: fixed;
            top: 50%;
            margin-top: -150px;
            left: 50%;
            margin-left: -150px;
            
        }
        
    </style>
    
    <body>
        <div class="main"></div>
        <div class='mask'></div>
        <div class='login'></div>
    </body>
</html>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章