简单弹窗的设置(CSS方式)

这篇博客通过CSS展示了如何创建一个基本的弹窗组件。弹窗包括一个消息框包裹层,具有固定位置、背景半透明效果,以及一个消息框内容区域和底部包含取消和确定按钮的操作栏。CSS样式定义了各个部分的布局、颜色和对齐方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<!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>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值