前端大屏背景动画效果

1、效果见视频

大屏背景动画效果

附上背景图

 附上标题背景图

 

2、主要css动画样式:

&-bg {
    width: 100%;
    height: calc(100% - 0.98rem);
    overflow: hidden;
    background: url(../assets/images/xz.png) no-repeat 0 0 / cover;
    position: absolute;
    bottom: 0;
    z-index: 1;
    &-mask {
      width: 2500px;
      height: 1600px;
      transform: rotate(-30deg) translateX(-500px) translateY(150px);
      transform-origin: 0 0;
    }
    &-mask1 {
      background-color: rgba(0, 0, 0, 0.7);
      width: 2500px;
      height: 1500px;
      animation: mask1 linear 20s infinite;
    }

    &-mask2 {
      background-color: rgba(0, 0, 0, 0);
      width: 2500px;
      height: 0px;
      animation: mask2 linear 20s infinite;
    }

    @keyframes mask2 {
      0%,
      80% {
        height: 0px;
      }
      95% {
        height: 200px;
      }
      100% {
        height: 0px;
      }
    }

    &-mask3 {
      background-color: rgba(0, 0, 0, 0.7);
      width: 2500px;
      height: 0px;
      animation: mask3 linear 20s infinite;
    }
    @keyframes mask3 {
      0%,
      80% {
        height: 200px;
      }
      100% {
        height: 1500px;
      }
    }
    @keyframes mask1 {
      0%,
      80% {
        height: 1500px;
      }
      100% {
        height: 200px;
      }
    }
  }

3、直接给上整个 .vue 代码,可复制粘贴看效果(上图保存到自己的文件夹,再改一下图片路径即可)

<template>
  <div class="main">
    <div class="main-head">
      <div class="main-head-title">
        <div>实验中心检测动态</div>
      </div>
      <div class="main-head-time">
        <div class="main-head-time-left">{{ date.week }}</div>
        <div class="main-head-time-center">{{ date.time }}</div>
        <div class="main-head-time-right">{{ date.day }}</div>
      </div>
    </div>
    <div class="main-body">
      <div class="box">
      </div>
    </div>
   <div class="main-bg">
        <div class="main-bg-mask">
          <div class="main-bg-mask1"></div>
          <div class="main-bg-mask2"></div>
          <div class="main-bg-mask3"></div>
        </div>
      </div>
  </div>
</template>

<script>
import models from "@/models";

export default {
  name: "DataviewIndex",
  props: {},
  components: {},
  data() {
    return {
      data: [],
      // 时间
      date: {
        week: "",
        time: "",
        day: "",
      },
      // 更新时间定时器
      dateTime: null,
    };
  },
  watch: {},
  methods: {
    // 获取时间
    getDate() {
      this.date.time = models.Day.GetNowTimeWithFormat();
      this.date.day = models.Day.GetNowDateWithFormat();
      this.date.week = models.Day.GetWeek();
    },
  },
  computed: {
    classOption() {
      return {
        step: 0.8, //滚动的速度
        limitMoveNum: 19, //开始无缝滚动的数据量 this.dataList.length
        hoverStop: true, //鼠标悬停,true/false
        direction: 1, //滚动的方向,0向下 1向上 2向左 3向右
        openWatch: true, //开启数据实时监控刷新dom,true/false
        singleHeight: 0, //滚动多少高度停留一次
        singleWidth: 0, //无缝不停止的滚动
        waitTime: 1000, //单步运动停止的时间(默认值1000ms)
      };
    },
  },
  created() {},
  mounted() {
    // 获取时间并每隔一秒获取一次
    this.dateTime = setInterval(() => {
      this.getDate();
    }, 1000);
  },
  

  destroyed() {
    clearInterval(this.dateTime);
  },
};
</script> 

<style scoped lang='scss'>
.main {
  width: 100%;
  height: 100%;
  background-color: #010a12;
  &-head {
    height: 0.98rem;
    background-image: url("@/assets/images/img-bg-view-title.png");
    background-size: 100% 100%;
    &-title {
      height: 0.65rem;
      display: flex;
      justify-content: center;
      & > div {
        width: 5rem;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 0.26rem;
        color: #f7f5f9;
        letter-spacing: 5px;
      }
    }
    &-time {
      height: calc(100% - 0.65rem);
      color: #f7f5f9;
      font-size: 0.16rem;
      position: relative;
      &-left {
        position: absolute;
        top: -0.04rem;
        left: 6.2rem;
      }
      &-center {
        position: absolute;
        top: 0.05rem;
        left: 9.3rem;
      }
      &-right {
        position: absolute;
        top: -0.04rem;
        left: 12.3rem;
      }
    }
  }
  &-body {
    height: calc(100% - 0.98rem);
  }
  &-bg {
    width: 100%;
    height: calc(100% - 0.98rem);
    overflow: hidden;
    background: url(../assets/images/xz.png) no-repeat 0 0 / cover;
    position: absolute;
    bottom: 0;
    z-index: 1;
    &-mask {
      width: 2500px;
      height: 1600px;
      transform: rotate(-30deg) translateX(-500px) translateY(150px);
      transform-origin: 0 0;
    }
    &-mask1 {
      background-color: rgba(0, 0, 0, 0.7);
      width: 2500px;
      height: 1500px;
      animation: mask1 linear 20s infinite;
    }

    &-mask2 {
      background-color: rgba(0, 0, 0, 0);
      width: 2500px;
      height: 0px;
      animation: mask2 linear 20s infinite;
    }

    @keyframes mask2 {
      0%,
      80% {
        height: 0px;
      }
      95% {
        height: 200px;
      }
      100% {
        height: 0px;
      }
    }

    &-mask3 {
      background-color: rgba(0, 0, 0, 0.7);
      width: 2500px;
      height: 0px;
      animation: mask3 linear 20s infinite;
    }
    @keyframes mask3 {
      0%,
      80% {
        height: 200px;
      }
      100% {
        height: 1500px;
      }
    }
    @keyframes mask1 {
      0%,
      80% {
        height: 1500px;
      }
      100% {
        height: 200px;
      }
    }
  }
}
</style>

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
前端大屏适配的代码可以参考以下示例,其中使用了CSS3的媒体查询和百分比布局来实现适配: ```html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>前端大屏适配示例</title> <style> /* 默认样式 */ * { margin: 0; padding: 0; } /* 大屏幕样式 */ @media screen and (min-width: 1024px) { /* 设置页面宽度为100% */ body { width: 100%; } /* 设置页面主体部分宽度为80% */ .main { width: 80%; margin: 0 auto; } /* 设置页面元素的字体大小为2em */ h1, p { font-size: 2em; } /* 设置图片宽度为50% */ img { width: 50%; } } /* 小屏幕样式 */ @media screen and (max-width: 1023px) { /* 设置页面宽度为100% */ body { width: 100%; } /* 设置页面主体部分宽度为90% */ .main { width: 90%; margin: 0 auto; } /* 设置页面元素的字体大小为1em */ h1, p { font-size: 1em; } /* 设置图片宽度为100% */ img { width: 100%; } } </style> </head> <body> <div class="main"> <h1>前端大屏适配示例</h1> <p>这是一个前端大屏适配的示例,通过使用CSS3的媒体查询和百分比布局来实现。</p> <img src="example.jpg" alt="示例图片"> </div> </body> </html> ``` 在上述代码中,通过设置 @media 查询来实现不同屏幕尺寸下的样式设置。在大屏幕下,设置了页面宽度为100%、页面主体部分宽度为80%、页面元素字体大小为2em、图片宽度为50%等样式。在小屏幕下,设置了页面宽度为100%、页面主体部分宽度为90%、页面元素字体大小为1em、图片宽度为100%等样式。通过这种方式,可以实现前端大屏适配。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值