js+css实现一个顶部横条弹出层消息提示通知代码

代码语言:html

所属分类:弹出层

代码描述:js+css实现一个顶部横条弹出层消息提示通知代码

代码标签: js css 顶部 横条 弹出层 消息 提示 通知

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

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

<head>
    <meta charset="UTF-8">
    <style>
        import url("https://fonts.googleapis.com/css?family=Montserrat:400,400i,700");
        :root {
          font-family: "Montserrat";
        }
        
        html,
        body {
          margin: 0;
          height: 100%;
        }
        
        body {
          display: flex;
          align-items: center;
          justify-content: center;
        }
        
        i {
          color: inherit;
        }
        
        .banners-container {
          position: fixed;
          top: 0;
          left: 0;
          width: 100%;
        }
        
        .banner {
          color: white;
          font-weight: 700;
          padding: 2rem;
          display: flex;
          flex-direction: row;
          align-items: center;
        }
        .banner .banner-message {
          flex: 1;
          padding: 0 2rem;
        }
        .banner .banner-close {
          display: flex;
          align-items: center;
          justify-content: center;
          padding: 0.5rem;
          border-radius: 4px;
          cursor: pointer;
          transition: background 0.3s;
        }
        .banner .banner-close:hover {
          background: rgba(0, 0, 0, 0.12);
        }
        
        .banner.success {
          background: #10c15c;
        }
        .banner.success::after {
          background: #10c15c;
        }
        .banner.error {
          background: #ed1c24;
        }
        .banner.error::after {
          background: #ed1c24;
        }
        .banner.info {
          background: #0b22e2;
        }
        .banner.info::after {
          background: #0b22e2;
        }
        
        .banner::after {
          content: "";
          position: absolute;
          height: 10%;
          width: 100%;
          bottom: 100%;
          left: 0;
        }
        
        .banner:not(.visible) {
          display: none;
          transform: translateY(-100%);
        }
        
        .banner.visible {
          box-shadow: 0 2px 2px 2px rgba(0, 0, 0, 0.12);
          animation-name: banner-in;
          animation-direction: forwards;
          animation-duration: 0.6s;
          animation-timing-function: ease-in-out;
          animation-fill-mode: forwards;
          animation-iteration-count: 1;
        }
        
        @keyframes banner-in {
          0% {
            transform: translateY(-100%);
          }
          50% {
            transform: translateY(10%);
          }
          100% {
            transform: translateY(0);
          }
        }
        .show-banner {
          appearance: none;
          background: #ededed;
          border: 0;
          padding: 1rem 2rem;
          border-radius: 4px;
          cursor: pointer;
          text-transform: uppercase;
     .........完整代码请登录后点击上方下载按钮下载查看

网友评论0