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
    }
     
     
     
  • 相关阅读:
    HDU 树型dp
    NOIP模拟 Math
    HTML5本地存储LocalStorage和sessionStorage
    数据结构与算法第一章答案
    堆和队列的应用之——简单计算器
    HITCS-LAB1 Linux 下C工具的应用
    cs:app 第二章homework(已完结)
    vim使用小结(1)
    学术英语写作(1)
    linux基础(2)
  • 原文地址:https://www.cnblogs.com/Super-scarlett/p/10000628.html
Copyright © 2011-2022 走看看