css3 mask 渐变动画另类写法

css mask 渐变动画另类写法  就是改变宽度做动画 里面渐变写死

    html,
    body {
      margin: 0;
      padding: 0;
    }
    .rect {
      height: 10px;
      width: 100vw;
      background-image: linear-gradient(to right, #000 80%, #fff);
    }
    .mask {
      -webkit-mask-image: linear-gradient(
        to right,
        rgba(0, 0, 0, 1) 80%,
        transparent
      );
      mask-image: linear-gradient(to right, rgba(0, 0, 0, 1) 80%, transparent);
    }
    html {
      font-size: 14px;
      line-height: 3;
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
        Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    }
    .tab-wrap {
      padding: 0 2em 0 1em;
      position: relative;
      width: 300px;
      /* height: 12px; */
      border-radius: 6px 6px 0 0;
      background-color: #333333;
      overflow: hidden;
      display: flex;
      justify-content: center;
      align-items: center;
      color: rgba(255, 255, 255, 0.8);
      display: inline-block;
    }
    .tab-wrap .tab {
      width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .tab .tab-text {
      white-space: nowrap;
    }
    .tab-wrap .close {
      position: absolute;
      right: 0;
      width: 2em;
      top: 0;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .cursor {
      user-select: none;
      cursor: default;
    }
    @supports (-webkit-mask-image: inherit) or (mask-image: inherit) {
      .tab-wrap .tab {
        text-overflow: clip;
        -webkit-mask-image: linear-gradient(
          to right,
          rgba(0, 0, 0, 1) calc(100% - 2em),
          transparent
        );
        mask-image: linear-gradient(
          to right,
          rgba(0, 0, 0, 1) calc(100% - 2em),
          transparent
        );
      }
    }



posted @ 2022-02-24 11:56  newmiracle宇宙  阅读(216)  评论(0编辑  收藏  举报