案例14-QQ延时显示弹框


<!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>QQ延时面板</title>

    <style>

        .wrap{

            width: 300px;

            height: 700px;

            border: 1px solid #000;

            box-shadow: 0 0 10px #000;

            position: absolute;

            right: 40px;

            top: 10px;

            border-radius: 10px;

        }

        .user{

            height: 150px;

            border-bottom: 1px solid rgb(70, 120, 212);

        }

        .user a{

            text-decoration: none;

            color: #000;

            position: absolute;

            right: 10px;

            top: 10px;

        }

        .avatar{

            width: 100px;

            height: 100px;

            border-radius: 50%;

            border: 2px solid rgb(57, 150, 236);

            position: absolute;

            left: 10px;

            top: 20px;

            cursor: pointer;

        }

        .info{

            width: 200px;

            height: 150px;

            position: absolute;

            background-color: rgb(238, 180, 180);

            left: -210px;

            top: 0;

            border-radius: 10px;

            box-shadow: 0 0 10px rgb(243, 88, 88);

            display: none;

        }

        .info p{

            text-indent: 10px;

            color: rgb(110, 6, 6);

        }

    </style>

</head>

<body>

    <div class="wrap">

        <div class="user">

            <a href="javascript:;">☓</a>

            <div class="avatar">

                <img src="./img.png" alt="">

            </div>

        </div>

        <div class="info">

            <p>昵称:开课吧</p>

            <p>地点:北京市 朝阳区</p>

        </div>

    </div>

<script>

function $(cssSelector){

    var els = document.querySelectorAll(cssSelector);

    return els.length > 1?els:els[0];

};  

/*

    css 方法,用来获取或设置样式

    只传:el,attr 获取样式

    el,attr,val: 设置样式

*/  

function css(el,attr,val){

    if(val === undefined){

        return getComputedStyle(el)[attr]

    }

    el.style[attr] = val;

(function(){

    var avatar = $(".avatar");

    var info = $(".info");

    var timer = 0;

    // avatar.onmouseover = function(){

    //     clearTimeout(timer);

    //     css(info,"display","block");

    // };

    // avatar.onmouseout = function(){

    //     clearTimeout(timer);

    //     timer = setTimeout(function(){

    //         css(info,"display","none");

    //     },200);

    // };

    // info.onmouseover = function(){

    //     clearTimeout(timer);

    // };

    // info.onmouseout = function(){

    //     clearTimeout(timer);

    //     timer = setTimeout(function(){

    //         css(info,"display","none");

    //     },200);

    // };

    info.onmouseover =  avatar.onmouseover = function(){

        clearTimeout(timer);

        css(info,"display","block");

    };

    info.onmouseout = avatar.onmouseout = function(){

        clearTimeout(timer);

        timer = setTimeout(function(){

            css(info,"display","none");

        },200);

    };

    // info.onmouseover = function(){

    //     clearTimeout(timer);

    //     css(info,"display","block");

    // };

 

})()    

</script>

</body>

</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值