在线示例

Fullscreen Red Alert

代码

<!DOCTYPE html&gt;
<html>
  <head>
    <title>Fullscreen Red Alert</title>
    <style>
      html,
      body {
        margin: 0;
        padding: 0;
        overflow: hidden;
      }

      :root {
        --alert-size: 120px;
      }

      #alertOverlay::before,
      #alertOverlay::after {
        content: "";
        position: absolute;
        width: var(--alert-size);
        height: 100%;
      }

      #alertOverlay > div::before,
      #alertOverlay > div::after {
        content: "";
        position: absolute;
        width: 100%;
        height: var(--alert-size);
      }

      #alertOverlay::before {
        background: linear-gradient(to right, red, transparent);
        top: 0;
        left: 0;
        transform: rotate(0deg);
      }

      #alertOverlay::after {
        background: linear-gradient(to left, red, transparent);
        top: 0%;
        left: 100%;
        transform: rotate(0deg) translate(calc(-1 * var(--alert-size)), 0px);
      }

      #alertOverlay > div::before {
        background: linear-gradient(to top, red, transparent);
        top: 0;
        left: 0;
        transform: rotate(180deg);
      }

      #alertOverlay > div::after {
        background: linear-gradient(to top, red, transparent);
        top: 100%;
        left: 0;
        transform: rotate(0deg) translate(0px, calc(-1 * var(--alert-size)));
      }

      #alertOverlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        box-sizing: border-box;
        opacity: 1;
        transition: opacity 0.5s;
        pointer-events: none;
        z-index: 1;
      }

      .alert-active {
        animation: blink 1s infinite;
      }

      @keyframes blink {
        0% {
          opacity: 0;
        }
        50% {
          opacity: 0.5;
        }
        100% {
          opacity: 0;
        }
      }
    </style>
  </head>
  <body>
    <div id="alertOverlay">
      <div></div>
    </div>

    <script>
      // 监听告警状态变化
      function setAlertState(active) {
        var alertOverlay = document.getElementById("alertOverlay");
        if (active) {
          alertOverlay.classList.add("alert-active");
        } else {
          alertOverlay.classList.remove("alert-active");
        }
      }

      // 设置告警状态激活
      setAlertState(true);
    </script>
  </body>
</html>

原文地址:https://blog.csdn.net/a571574085/article/details/131051636

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_34522.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注