模态对话框以及定位

模态对话框

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>模态对话框2</title>
    <style>
        .shadow {
            background-color: black;
            height: 1000px;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            opacity: 0.4;
            z-index: 100;
            display: none;

        }

        .content {
            background-color: white;
            width: 300px;
            height: 400px;
            position: fixed;
            top: 100px;
            left: 500px;
            right: 200px;
            z-index: 2000;
            display: none;

        }
    </style>
</head>
<body>
<button id="btn">点我</button>
<div class="shadow"></div>
<div class="content">
    <form action="">
        用户名<input type="text">
        <input type="submit">
        <input type="button" id="cancel" value="取消">
    </form>
</div>
</body>
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>

<script>
    console.log(jQuery)
</script>
<script>
    $('#btn').click(function () {
        //console.log(123);
        //$(".shadow").css('display','block');
        //$(".content").css('display','block');
        $(".shadow").show();
        $(".content").show();
    });

    $('#cancel').click(function () {
        $(".shadow").hide();
        $(".content").hide();
    })
</script>
</html>


定位

绝对定位:以页面为参考点进行移动,固定定位是绝对定位的一种
相对定位:以标签元素本身作为移动对象
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Title</title>
    <style>
        .div1{
            width: 500px;
            height: 500px;
            background-color: red;
            position: relative;
            bottom:  100px;
            right: 100px;



        }

        {#.div2{#}
        {#    width: 500px;#}
        {#    height: 500px;#}
        {#    background-color: blue;#}
        {#    position: absolute;#}
        {#}#}
    </style>
</head>
<body>
<div class="div1"></div>
<div class="div2"></div>
</body>
</html>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容