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
    }
     
     
     
  • 相关阅读:
    jquery queryBuilder过滤插件的使用
    前端跨域问题
    [BZOJ 3326] 数数
    [BZOJ 2427] 软件安装
    [BZOJ 3675] 序列分割
    [Atcoder Grand Contest 004] Tutorial
    [P2831] 愤怒的小鸟
    [Atcoder Regular Contest 065] Tutorial
    [P3806] Divide and Conquer on Tree
    [POJ 1741] Tree
  • 原文地址:https://www.cnblogs.com/Super-scarlett/p/10000628.html
Copyright © 2011-2022 走看看