1. 程式人生 > >簡單彈窗的設定(CSS方式)

簡單彈窗的設定(CSS方式)

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style lang="">
        .message-box-wrapper {
            position: fixed;
            left: 0;
            right: 0;
            top: 0;
            bottom: 0;
            text-align: center;
            background-color: rgba(0, 0, 0, .3)
        }
        
        .message-box-wrapper::after {
            content: "";
            display: inline-block;
            height: 100%;
            width: 0;
            vertical-align: middle;
        }
        
        .message-box {
            display: inline-block;
            vertical-align: middle;
            position: relative;
            width: 300px;
            height: 200px;
            background: #ffffff;
        }
        
        .message-box-content {
            padding: 30px 20px;
        }
        
        .message-box-btns {
            position: absolute;
            bottom: 0;
            width: 100%;
            height: 50px;
        }
        
        .message-box-cancel,
        .message-box-confirm {
            float: left;
            width: 50%;
            height: 100%;
            line-height: 50px;
            color: #ffffff;
        }
        
        .message-box-cancel {
            background-color: #8f9498;
        }
        
        .message-box-confirm {
            background-color: #FF6400;
        }
    </style>
</head>

<body>
    <div class="message-box-wrapper">
        <div class="message-box">
            <div class="message-box-header"></div>
            <div class="message-box-content">this is content</div>
            <div class="message-box-btns">
                <div class="message-box-cancel">取消</div>
                <div class="message-box-confirm">確定</div>
            </div>
        </div>
    </div>
</body>

</html>