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
Table of contents 1. Custom instructions 1. Regis...
This article uses examples to illustrate the usag...
Preface: In MySQL, the master-slave architecture ...
Install using the MSI installation package Downlo...
useState useState adds some internal state to a c...
This article shares the specific code of the pull...
<br />This article will briefly introduce yo...
Effect demo.html <html> <head> <me...
Table of contents Written in front Preface What i...
Startups often bring us surprises with their unco...
1. Some tips on classes declared with class in re...
As shown below: SELECT count(DISTINCT(a.rect_id))...
Table of contents 1. Background knowledge 1. Intr...
One of the most important features of a style she...
Use navicat to test and learn: First use set auto...