zoukankan      html  css  js  c++  java
  • 用原生html与js写一个dialog

    实现效果:

    HTML代码:

    <body>
        <button onclick="showDialog()">点击展示dialog</button>
        <dialog class="dialog">
            <div class="dialog-header">
                这是标题
                <div class="close-btn" onclick="closeDialog()"></div>
            </div>
            <div class="dialog-content">
                这里是内容
            </div>
        </dialog>
    </body>

    CSS代码:

    .dialog {
            height: 400px;
            width: 600px;
            top: 50%;
            left: 50%;
            transform: translate(-50%,-50%);
            position: absolute;
            border: none;
            border-radius: 20px;
            padding: 0 20px;
        }
        .dialog-header {
            height: 50px;
            width: 100%;
            line-height: 50px;
            position: relative;
            border-bottom: rgb(180, 179, 179) 1px solid;
        }
        .close-btn {
            width: 30px;
            height: 100%;
            display: inline-block;
            position: absolute;
            right: 0px;
            cursor: pointer;
            background: url('../test/close.png') no-repeat 50% 50%;
        }

    JS代码:

    function showDialog() {
        // 展示
        document.getElementsByClassName('dialog')[0].showModal();
    }
    function closeDialog() {
        // 隐藏
        document.getElementsByClassName('dialog')[0].close();
    }

    转自:https://blog.csdn.net/DZY_12/article/details/112271687 

  • 相关阅读:
    springMVC
    自动装配
    HTTP Status 500
    this compilation unit is not on the build of a java project
    Struct2提交表单数据到Acion
    ResultMap
    MyEclipse 代码自动提示
    xe mysql
    java Study 基础 1
    InterfaceConnect
  • 原文地址:https://www.cnblogs.com/vickylinj/p/14389863.html
Copyright © 2011-2022 走看看