zoukankan      html  css  js  c++  java
  • vue--公告轮播

    html:

     
    <div class="news" v-if="news.length > 0" >
      <ul class="marquee_list" :class="{ marquee_top : animate }">
        <li v-for="item in news">{{item.title}}</li>
      </ul>
    </div>
     
    js:
     
    export default {
      data(){
        return {
          news:[],
          animate:false
        }
       },
      mounted(){
        this.showMarquee();
      },
      methods:{
        showMarquee: function () {
          this.animate = true;
          setTimeout(()=>{
            this.news.push(this.news[0]);
            this.news.shift();
            this.animate = false;
          },500)
        }
      }
    }
     
     
    CSS:
     
    .news {
    position: relative;
    overflow: hidden;
    padding: 0.1rem .3rem;
    height: .84rem;
    box-sizing: border-box;
    ">#fff;
    &::before{
    content: "";
    .74rem;
    height: .64rem;
    display: block;
    overflow: hidden;
    background-image: url("../images/new_icon.png");
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    float: left;
    }
    ul{
    padding-left: 1.24rem;
    box-sizing: border-box;
    100%;
    li{
    white-space: nowrap;
    100%;
    text-overflow: ellipsis;
    height: .64rem;
    line-height: .64rem;
    font-size: .3rem;
    display: block;
    overflow: hidden;
    padding: .1rem;
    }
    }
    }
    .marquee_list{
    position: absolute;
    top:0px;
    left: 0px;
    }

    .marquee_top {
    transition: all 0.5s;
    margin-top: -.84rem
    }
     
     
     
  • 相关阅读:
    Matplotlib
    Numpy&Pandas
    莫凡《机器学习》笔记
    李宏毅《1天搞懂深度学习》笔记
    Git客户端使用教程
    像素级压缩感知图像融合的论文
    二分图【洛谷P2175】 小Z的游戏分队
    模板【洛谷P3390】 【模板】矩阵快速幂
    模板 可并堆【洛谷P3377】 【模板】左偏树(可并堆)
    LCA SP913 QTREE2
  • 原文地址:https://www.cnblogs.com/Super-scarlett/p/10000628.html
Copyright © 2011-2022 走看看