Vue3 implements CSS infinite seamless scrolling effect

Vue3 implements CSS infinite seamless scrolling effect

This article example shares the specific code of vue3 to achieve CSS infinite seamless scrolling effect for your reference. The specific content is as follows

template

Double-layer div nesting for hidden scrolling display

<div class="list-container">
  <div class="marquee" id="carList">
    <template v-for="(item, index) in dataMap.list" :key="index">
      <div class="list-item">
        <div class="item-name text-overflow">{{ item.name }}</div>
        <div class="item-road text-overflow">{{ item.road }}</div>
      </div>
    </template>
  </div>
</div>

script

Copy the content in the DOM element and connect to the last scrolling effect

export default defineComponent({
  setup() {
    const dataMap = reactive({
      list: [
        { name: '浙A89268', road: '游8路', status: 0 },
        { name: '浙A89268', road: '游8路', status: 0 },
        { name: '浙A89268', road: '游8路', status: 1 },
        { name: '浙A89268', road: '游8路', status: 0 },
        { name: '浙A89268', road: '游8路', status: 1 },
        { name: '浙A89268', road: '游1路', status: 0 },
      ],
    });
    onMounted(() => {
      const marquee = document.getElementById('carList');
      marquee.innerHTML = marquee.innerHTML + marquee.innerHTML;
    });
  }
})

style

CSS handwriting animation effect

.list-container {
  width: 720px;
  height: 170px;
  margin-left: 13px;
  overflow: hidden;
  position: relative;
}
//Infinite scroll.marquee {
  //animation-delay: -5s;
  animation: marquee 15s linear infinite;
}
.marquee:hover {
  animation-play-state: paused;
}
@keyframes marquee {
  0% {
    transform: translateY(0%);
  }
  100% {
    transform: translateY(-51%); //This is not -100%!
  }
} 

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Vue achieves seamless upward scrolling effect of messages
  • Realize seamless scrolling effect based on vue-seamless-scroll
  • Detailed explanation of how to use vue-seamless-scroll seamless scrolling component
  • Vue achieves seamless scrolling of infinite messages
  • Vue implements simple seamless scrolling effect
  • Vue implements seamless scrolling effect of list
  • Vue implements seamless vertical scrolling of lists
  • Vue implements seamless scrolling of lists
  • Seamless scrolling effect based on vue.js
  • Vue or css animation to achieve seamless scrolling of the list upwards

<<:  What should I do if I want to cancel an incorrect MySQL command?

>>:  How to hide the version number in Nginx

Recommend

mysql charset=utf8 do you really understand what it means

1. Let's look at a table creation statement f...

Inspiring Design Examples of Glossy and Shiny Website Design

This collection showcases a number of outstanding ...

JavaScript to achieve elastic navigation effect

This article shares the specific code for JavaScr...

Solution to Docker image downloading too slowly

Docker image download is stuck or too slow I sear...

How to reset the root password in CentOS7

There are various environmental and configuration...

18 Web Usability Principles You Need to Know

You can have the best visual design skills in the...

Solution to the problem of saving format in HTML TextArea

The format of textarea can be saved to the databas...

Six tips to increase web page loading speed

Secondly, the ranking of keywords is also related ...

Vue axios interceptor commonly used repeated request cancellation

introduction The previous article introduced the ...

JavaScript color viewer

This article example shares the specific code of ...

Some things to note about varchar type in Mysql

Storage rules for varchar In versions below 4.0, ...

MySQL Community Server compressed package installation and configuration method

Today, because I wanted to install MySQL, I went ...