CSS3 transition to implement notification message carousel

CSS3 transition to implement notification message carousel

Message carousel effect

Vue version, copy it to the file and use it

<template>
  <!-- Carousel View-->
  <div id="carousel-view">
    <!-- Carousel List-->
    <ul id="carousel-list-view" :class="{ 'carousel-animated':isAnimated }">
      <li v-for="(item, index) in dataSource" :key="index">{{ item }}</li>
    </ul>
  </div>
</template>

<script>
export default {
  data () {
    return {
      // Start animation isAnimated: false,
      // Carousel data dataSource: ['dzm', 'xyq', '啊啊']
    }
  },
  created () {
    // Start the timer setInterval(this.scroll, 1000)
  },
  methods: {
    // Scroll animation scroll () {
      // Start animation this.isAnimated = true
      // Countdown animation time setTimeout(() => {
        // Add the first element of the array to the end of the array this.dataSource.push(this.dataSource[0])
        // Remove the first element of the array this.dataSource.shift()
        // Turn off animation this.isAnimated = false
        // The animation time needs to be consistent with the time set in .carousel-animated}, 500)
    }
  }
}
</script>

<style scoped>
#carousel-view {
  width: 100%;
  height: 32px;
  background-color: red;
  overflow: hidden;
}
#carousel-list-view {
  margin: 0;
  padding: 0;
  list-style: none;
}
#carousel-list-view li {
  line-height: 32px;
  height: 32px;
}
.carousel-animated {
  transition: transform 0.5s;
  transform: translateY(-32px);
}
</style>

This is the end of this article about how to use CSS3 transition to implement a notification message carousel. For more information about CSS3 transition carousel, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

<<:  How to make a website front end elegant and attractive to users

>>:  Implementation of vue-nuxt login authentication

Recommend

mysql8.0.23 msi installation super detailed tutorial

1. Download and install MySql Download MySql data...

Using cursor loop to read temporary table in Mysql stored procedure

cursor A cursor is a method used to view or proce...

Regular expression usage in CSS selectors

Yes, CSS has regular expressions too (Amen) Two p...

5 Easy Ways to Free Up Space on Ubuntu

Preface Most people will probably perform this op...

Understanding of the synchronous or asynchronous problem of setState in React

Table of contents 1. Is setState synchronous? asy...

Share a Markdown editor based on Ace

I think editors are divided into two categories, ...

Initial summary of the beginner's website building tutorial

After writing these six articles, I started to fee...

Web page HTML code explanation: ordered list and unordered list

In this section, we will learn about list element...

JS implements city list effect based on VUE component

This article example shares the specific code for...

How to export mysql query results to csv

To export MySQL query results to csv , you usuall...

Steps to configure nginx ssl to implement https access (suitable for novices)

Preface After deploying the server, I visited my ...

How to change the domestic image source for Docker

Configure the accelerator for the Docker daemon S...

Insufficient memory problem and solution when docker starts elasticsearch

question Insufficient memory when docker installs...