告警动画并弹窗

167 阅读1分钟

先上效果图:

动画.gif

代码:

<!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>
      .warn_box {
        width: 60px;
        height: 60px;
        position: relative;
        margin: 100px auto;
      }
      .warn_box .dot {
        position: absolute;
        width: 23px;
        height: 23px;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
      }
      .warn_box .dot img {
        width: 100%;
        height: 100%;
      }

      .warn_box .pulse {
        background: rgba(252, 0, 0, 0.7) !important;
        -webkit-animation: warn 0.9s ease-out;
        -moz-animation: warn 0.9s ease-out;
        animation: warn 0.9s ease-out;
        -webkit-animation-iteration-count: infinite;
        -moz-animation-iteration-count: infinite;
        animation-iteration-count: infinite;
        box-shadow: 1px 1px 30px #f00;
        width: 100%;
        height: 100%;
        box-sizing: border-box;
        border: 2px solid #d13613;
        background: rgba(252, 0, 0, 0.9);
        border-radius: 50%;
        z-index: 100;
        opacity: 0;
      }
      .warn_list {
        box-sizing: border-box;
        width: 300px;
        height: 0;
        overflow: auto;
        background: #271938;
        border-radius: 10px;
        position: absolute;
        top: 60px;
        right: 0px;
        transition: height 0.3s;
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 0 10px;
      }

      .warn_list .every_info {
        width: 95%;
        line-height: 25px;
        padding: 10px 5px 40px 5px;
        border: 1px solid #1e81fc;
        margin-top: 10px;
        border-radius: 5px;
        position: relative;
      }
      .warn_list .every_info .content {
        color: #fd513e;
      }
      .warn_list .every_info .date {
        position: absolute;
        right: 5px;
        bottom: 5px;
        font-size: 14px;
        color: #fff;
      }
      .warn_box:hover .warn_list {
        width: 300px;
        height: 400px;
      }

      @keyframes warn {
        0% {
          -o-transform: scale(0);
          transform: scale(0);
          opacity: 1;
        }
        100% {
          -o-transform: scale(1);
          transform: scale(1);
          opacity: 0;
        }
      }
    </style>
  </head>
  <body>
    <div class="warn_box" v-if="warnData.length">
      <div class="dot">
        <img src="./warn.gif" alt="" />
      </div>
      <div class="pulse"></div>
      <div class="warn_list">
        <div class="every_info">
          <span class="content">告警信息</span>
          <span class="date">2024.3.11</span>
        </div>
      </div>
    </div>
  </body>
</html>

warn.gif图片

warn.gif