CSS3 动画实践:用 @keyframes 实现热点图

思路

1、中国地图作为背景,将一个盒子定位到想要的位置;
2、通过三个子盒子,添加阴影,设置时间段对应的动画以及透明度;
3、将后两个盒子适当延时;

效果

CSS3 动画实践:用 @keyframes 实现热点图_第1张图片

代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    
    <style>
        .map {
     
            position: relative;
            margin: auto;
            width: 615px;
            height: 506px;
            background: url("../res/Map.jpg") no-repeat;
        }

        .dotted {
     
            position: absolute;
            left: 270px;
            top: 118px;
            width: 8px;
            height: 8px;
            background-color: red;
            border-radius: 50%;
        }

        .map div[class ^= "pulse"] {
     
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%,-50%);
            width: 8px;
            height: 8px;
            box-shadow: 0 0 12px rgb(252, 55, 55);
            border-radius: 50%;
            animation: hot 1.5s linear infinite;
        }

        .map .dotted .pulse2 {
     
            animation-delay: 0.4s;
        }

        .map .dotted .pulse3 {
     
            animation-delay: 0.8s;
        }

        @keyframes hot {
     
            0%{
     }
            70% {
     
                width: 40px;
                height: 40px;
                opacity: 1;
            }
            100% {
     
                width: 70px;
                height: 70px;
                opacity: 0;
            }
        }
    </style>
</head>
<body>
    <div class="map">
        <div class="dotted">
            <div class="pulse1"></div>
            <div class="pulse2"></div>
            <div class="pulse3"></div>
        </div>
    </div>
</body>
</html>

你可能感兴趣的:(CSS,html5,css,css3,定位)