首页 > 其他分享 >点击div打开弹窗,点击其他区域关闭弹窗

点击div打开弹窗,点击其他区域关闭弹窗

时间:2023-06-29 14:11:06浏览次数:56  
标签:flex document height 点击 background div font display 弹窗

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .windowClass{
            height:100px;
            width:100px;
            border: 1px solid rosybrown;
        }
        .upContent{
            background: linear-gradient(150deg, rgba(24,41,114,0) 0%, rgba(10,18,62,0.21) 100%);
            box-shadow: inset 0px 0px 21px 0px rgba(26,73,177,0.63);
            border: 1px solid;
            border-image: linear-gradient(116deg, rgba(77, 166, 239, 0), rgba(37, 109, 219, 1)) 1 1;
            display: flex;
            padding: 7px;
            margin-bottom: 2px;
        }
        .upContent img {
            width: 26px;
            height: 26px;
            margin-right: 11px;
        }
        .upContent span{
            font-size: 16px;
            font-family: SourceHanSansSC-Regular, SourceHanSansSC;
            font-weight: 400;
            color: #FFFFFF;
            line-height: 24px;
            letter-spacing: 1px;
        }
        /* 下方样式 */
        .downContent{
            background-image: url('../img/housePersonBac.png');
            background-repeat: no-repeat;
            background-size: 100% 100%;
            display: flex;
            padding: 23px 42px 12px 33px;
        }
        /* 下方 左侧头像 */
        .downContent .downLeft{
            display: flex;
            flex-direction: column;
            margin-right: 43px;
            align-items: center;
        }
        .downContent .downLeft img{
            width: 52px;
            height: 52px;
            box-shadow: inset 0px 1px 14px 0px #2BA1FF;
            border-radius: 25px;
            border: 2px solid #2BA1FF;
        }
        /* 下方 右侧人数 */ 
        .downContent .downRight{
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        .number{
            background-image: url('../img/peopleNum.png');
            background-size: 100% 100%;
            text-align: center;
            line-height: 56px;
            width: 56px;
            height: 56px;
            font-size: 20px;
            font-family: Helvetica-Bold, Helvetica;
            font-weight: bold;
            color: #CFEAFF;
        }
        /* 姓名 */
        .downName{
            font-size: 14px;
            font-family: SourceHanSansSC-Regular, SourceHanSansSC;
            font-weight: 400;
            color: #FFFFFF;
            line-height: 20px;
        }
        /* 业主 */
        .identity{
            background: linear-gradient(180deg, #80A4FF 0%, rgba(128,164,255,0) 53%, #80A4FF 100%);
            border-radius: 14px;
            opacity: 0.8;
            font-size: 12px;
            font-family: SourceHanSansSC-Regular, SourceHanSansSC;
            font-weight: 400;
            color: #FFFFFF;
            line-height: 18px;
            padding: 2px 7px;
        }
    </style>
</head>
<body>
    <div class="windowClass" id="windowID"></div>
    <div style="position: absolute; display: none;" id="messageID">
        <div class="upContent">
            <img src="../img/home.png" alt="" onclick="closeFun()">
            <span>108号楼3单元402 </span>
        </div>
        <div class="downContent">
            <div class="downLeft">
                <img src="../img/people.jpg" alt="">
                <div>
                    <span class="downName">刘志斌</span>
                    <span class="identity">业主</span>
                </div>
                
            </div>
            <div class="downRight">
                <span class="number">6</span>
                <span class="downName">人数</span>
            </div>
        </div>
    </div>
    <script>
        document.getElementById('windowID').addEventListener('click',function (e) {
            //mousemove 只要鼠标一移动,就会触发事件
            //获取鼠标最新的坐标
            // console.log(e.pageY)
            // console.log(e.pageX);
            let x = e.pageX
            let y = e.pageY
            document.getElementById('messageID').style.display = 'inline-block'
            document.getElementById('messageID').style.left = x + 'px'
            document.getElementById('messageID').style.top = y + 'px'
            e.stopPropagation();//阻止冒泡
        })

        document.addEventListener('click',function(){
            document.getElementById('messageID').style.display = 'none';//隐藏
        });

        function closeFun(){
            document.getElementById('messageID').style.display="none";
        }
    </script>
</body>
</html>

 

标签:flex,document,height,点击,background,div,font,display,弹窗
From: https://www.cnblogs.com/brillant/p/17514081.html

相关文章

  • React - 判断当前点击是组件的外部或内部
    1.先获取当前要监听的那个组件的refimportReact,{useRef}from'react';//类组件获取this.Ref=React.createRef();//函数组件获取constRef=useRef();2.通过addEventListener来全局监听document.addEventListener("mousedown",(e)=>{if(Ref.contains(e.ta......
  • CodeTON Round 5 (Div. 1 + Div. 2, Rated, Prizes!) D. Tenzing and His Animal Fri
    题面是真的抽象,翻译为人话之后大概就是,对于每个选择的集合当中,1必须选,n一定不能选,每个限制条件的意思是如果u和v不在一个集合里则最能玩y时间,则u或v独自玩最多玩y时间如果在同一集合则可以玩无限时间因此如果n和1不连通的话则一定为inf,否则的话就一定有限制,因为n一定不能选,则和......
  • 618技术揭秘 - 大促弹窗搭投实践
    背景618大促来了,对于业务团队来说,最重要的事情莫过于各种大促营销。如会场、直播带货、频道内营销等等。而弹窗作为一个极其重要的强触达营销工具,通常用来渲染大促氛围、引流主会场、以及通过频道活动来提升频道复访等。因此,如果能将运营的策略及想法快速转化为弹窗的内容并触......
  • Codeforces Round 881 (Div. 3)
    失踪人口回归VP打的A.SashaandArrayColoringintn;inta[maxN];voidsolve(){ n=rd(); fp(i,1,n)a[i]=rd(); sort(a+1,a+n+1); llans=0; for(inti=1;i*2<=n;++i) ans+=(a[n-i+1]-a[i]); cout<<ans<<endl;}B.LongLongintn;inta[maxN......
  • uniapp,微信小程序点击按钮打开地图进行导航
    uniapp示例:<viewclass="order-contact-item"style="width:50%;text-align:center;"@tap="openMapNavigation">导航商家</view> //js函数打开导航 openMapNavigation(){ varthat=this; uni.getLocation({ type:'g......
  • maltab 利用不同方式(自编高斯赛德尔迭代函数,逆矩阵,左除(\)运算)求解线性方程组的速度
    参考:matlabhelp文档:mldivide实际测试比较,这里K_Tem为一个2398*2398的稀疏矩阵,Guass_Seidal是自己写的高斯赛德尔迭代函数 ......
  • CF1834 Div.2 做题记录
    A题面分类讨论即可点击查看代码#include<bits/stdc++.h>#defineullunsignedlonglong#definelllonglong#definepiipair<int,int>#definepdipair<double,int>#definepbpush_back#defineeps1e-9#definempmake_pairusingnamespacestd;namesp......
  • [LeetCode] 1071. Greatest Common Divisor of Strings
    Fortwostrings s and t,wesay"t divides s"ifandonlyif s=t+...+t (i.e., t isconcatenatedwithitselfoneormoretimes).Giventwostrings str1 and str2,return thelargeststring x suchthat x dividesboth str1 and str2.Exam......
  • JQ 其它的点击事件用法
    demo.html<html><head><title></title><metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/><style>.over{ color:red; background:#888;}</style><scriptsrc="js/j......
  • 关于word、excel点击保存无反应的问题
    word和excel文档无法保存,点击保存按钮没有反应,新建文档也没法保存,但是点击关闭窗口是会跳出是否保存对话框方法/步骤11、32位操作系统的方法是:运行regedit—HKEYLOCALMACHINE—SOFTWARE—microsoft—office—word—addins—***addins—把LoadBehavior键值从3改为0。2、64位操作......