前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >10.14 如何实现一个居中弹出的窗口?

10.14 如何实现一个居中弹出的窗口?

作者头像
LIYI
修改2021-01-12 15:51:44
1.6K0
修改2021-01-12 15:51:44
举报
文章被收录于专栏:艺述论专栏

如何实现一个居中弹出的窗口?

效果

代码

代码语言:javascript
复制
    <h1>如何实现一个居中弹出的窗口?</h1>


    <div id="panel1" class="panel-mask">
        <div class="panel">
            <style>
                .panel-mask {
                    height: 100%;
                    position: fixed;
                    display: block;
                    top: 0;
                    bottom: 0;
                    left: 0;
                    right: 0;
                    background-color: rgba(0, 0, 0, 0.78);
                }


                .panel {
                    position: relative;
                    width: 500px;
                    height: 300;
                    background-color: #f9f9f9;
                    transform: translate(50%, 50%);
                    padding: 20px;
                    border-radius: 5px;
                    box-shadow: 5px 5px 20px 10px rgba(0, 0, 0, .5);
                }


                .close-btn {
                    position: absolute;
                    right: 20px;
                    background-color: grey;
                    width: 20px;
                    text-align: center;
                    cursor: pointer;
                    line-height: 18px;
                    color: snow;
                    user-select: none;
                    border-style: outset;
                    border-width: 2px;
                }
                .close-btn:hover{
                    /* translate: scale(2); */
                    background-color: silver;
                    color: black;
                }
                .close-btn:active{
                    border-style: inset;
                }
            </style>
            <script>
                function popupPanel() {
                    $("#panel1").css("display", "block")
                }
                function closePanel() {
                    $("#panel1").css("display", "none")
                }
            </script>
            <div class="close-btn" onclick="closePanel()">×</div>
            <h3 style="margin-bottom: 15px;">标题</h3>
            <p>文本描述</p>
        </div>
    </div>


    <button onclick="popupPanel()">弹出</button>
    <button onclick="closePanel()">关闭</butt

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2020-10-15,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 艺述论 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 如何实现一个居中弹出的窗口?
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档