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

Getting Started with Vue 3.0 Custom Directives

Table of contents 1. Custom instructions 1. Regis...

MySQL conditional query and or usage and priority example analysis

This article uses examples to illustrate the usag...

Detailed analysis of MySQL master-slave replication

Preface: In MySQL, the master-slave architecture ...

Steps to install MySQL 5.7.10 on Windows server 2008 r2

Install using the MSI installation package Downlo...

Detailed example of using useState in react

useState useState adds some internal state to a c...

React native ScrollView pull down refresh effect

This article shares the specific code of the pull...

XHTML tutorial, a brief introduction to the basics of XHTML

<br />This article will briefly introduce yo...

HTML+VUE paging to achieve cool IoT large screen function

Effect demo.html <html> <head> <me...

Chrome plugin (extension) development guide (complete demo)

Table of contents Written in front Preface What i...

17 excellent web designs carefully crafted by startups

Startups often bring us surprises with their unco...

Summary of constructor and super knowledge points in react components

1. Some tips on classes declared with class in re...

MySQL column to row conversion and year-month grouping example

As shown below: SELECT count(DISTINCT(a.rect_id))...

A brief analysis of the function calling process under the ARM architecture

Table of contents 1. Background knowledge 1. Intr...

CSS Tutorial: CSS Attribute Media Type

One of the most important features of a style she...

Mysql queries the transactions being executed and how to wait for locks

Use navicat to test and learn: First use set auto...