HTML&CSS :实时报警图标

这段代码创建了一个带有动态点动画的警报加载器,通过 CSS 技术实现了点的动态变化效果,为页面添加了视觉吸引力和动态感。

演示效果

在这里插入图片描述

HTML&CSS

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>公众号关注:前端Hardy</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            background: #212121;
        }

        .loader {
            width: fit-content;
            height: fit-content;
            background-color: rgb(58, 58, 58);
            border-radius: 7px;
            padding: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            cursor: pointer;
            transition: 0.2s;
        }

        .loader:hover {
            background-color: rgb(26, 26, 26);
        }

        .loader:hover svg {
            color: white;
        }

        .loader svg {
            color: rgba(255, 255, 255, 0.651);
            transform: scale(1.2);
            transition: 0.2s;
        }

        .point {
            position: absolute;
            bottom: 5px;
            left: 5px;
            width: 6px;
            height: 6px;
            background-color: rgb(255, 1, 1);
            border-radius: 25px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .point::before {
            content: "";
            position: absolute;
            width: 1px;
            height: 1px;
            background-color: rgb(255, 1, 1);
            border-radius: 25px;
            animation: loop 1s 0s infinite;
        }

        @keyframes loop {
            0% {
                background-color: rgb(255, 1, 1);
                width: 1px;
                height: 1px;
            }

            100% {
                background-color: rgba(255, 1, 1, 0);
                width: 30px;
                height: 30px;
            }
        }
    </style>
</head>

<body>
    <div class="loader">
        <svg viewBox="0 0 24 24" fill="none" height="24" width="24" xmlns="http://www.w3.org/2000/svg"
            aria-hidden="true" class="w-6 h-6 text-gray-800 dark:text-white">
            <path
                d="M12 5.365V3m0 2.365a5.338 5.338 0 0 1 5.133 5.368v1.8c0 2.386 1.867 2.982 1.867 4.175 0 .593 0 1.292-.538 1.292H5.538C5 18 5 17.301 5 16.708c0-1.193 1.867-1.789 1.867-4.175v-1.8A5.338 5.338 0 0 1 12 5.365ZM8.733 18c.094.852.306 1.54.944 2.112a3.48 3.48 0 0 0 4.646 0c.638-.572 1.236-1.26 1.33-2.112h-6.92Z"
                stroke-width="2" stroke-linejoin="round" stroke-linecap="round" stroke="currentColor"></path>
        </svg>
        <div class="point"></div>
    </div>

</body>

</html>

HTML 结构

  • loader: 创建一个类名为“loader”的 div 元素,用于包含加载器的各个部分。
  • svg: 创建一个 SVG 图标,用于显示加载器的图形。
  • point: 创建一个类名为“point”的 div 元素,用于显示动态变化的红色点。

CSS 样式

  • body: 设置页面的边距、填充、高度、显示方式和对齐方式,背景色为深灰色。
  • .loader: 设置加载器的样式,包括尺寸、背景色、圆角、内边距、显示方式和对齐方式。
  • .loader:hover: 设置鼠标悬停在加载器上时的背景色。
  • .loader:hover svg: 设置鼠标悬停在加载器上时 SVG 图标的颜色。
  • .loader svg: 设置 SVG 图标的样式,包括颜色、缩放和过渡效果。
  • .point: 设置动态点的样式,包括位置、尺寸、背景色、圆角和对齐方式。
  • .point::before: 设置动态点的伪元素,用于创建动态变化的效果。
  • @keyframes loop: 定义动态点的变化动画,使点从一个小圆点逐渐扩展并消失。
  • 动态点通过@keyframes loop和animation属性实现,从一个小圆点逐渐扩展并消失,形成一个循环动画。
  • SVG图标在鼠标悬停时会变为白色,背景色也会变暗,增强视觉效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值