提交 ec2ac2ce 编写于 作者: Z zfz5720

Auto Commit

上级 385e6607
...@@ -2,8 +2,12 @@ ...@@ -2,8 +2,12 @@
import { ref, nextTick } from 'vue'; import { ref, nextTick } from 'vue';
const noticeList = ref([]); const noticeList = ref([]);
const startScroll = async () => { const getNoticeList = async () => {
const list = ['测试文字', '哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈']; const list = [
'测试文字',
'11111111111111111111111111111111111111111111111111111111',
'哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈',
];
noticeList.value = list; noticeList.value = list;
nextTick(() => { nextTick(() => {
const content = document.querySelector('.scroll-content'); const content = document.querySelector('.scroll-content');
...@@ -17,38 +21,28 @@ const startScroll = async () => { ...@@ -17,38 +21,28 @@ const startScroll = async () => {
}); });
}; };
startScroll(); getNoticeList();
</script> </script>
<template> <template>
<div class="text-scroll"> <div class="scroll-container">
<div class="scroll-container"> <div class="scroll-content">
<div class="scroll-content"> <div v-for="(item, index) in noticeList" :key="item + index" class="item">
<div {{ item }}
v-for="(item, index) in noticeList"
:key="item + index"
class="item"
>
{{ item }}
</div>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<style scoped> <style scoped>
.text-scroll { .scroll-container {
display: flex; display: flex;
align-items: center; align-items: center;
background: red; background: red;
width: 800px; width: 500px;
}
.scroll-container {
overflow-x: hidden; /* 启用水平滚动 */ overflow-x: hidden; /* 启用水平滚动 */
overflow-y: hidden; /* 隐藏垂直滚动条 */ overflow-y: hidden; /* 隐藏垂直滚动条 */
white-space: nowrap; /* 防止内容换行 */ white-space: nowrap; /* 防止内容换行 */
width: 100%; /* 设置容器宽度,占满父容器 */
position: relative; position: relative;
z-index: 99; z-index: 99;
} }
...@@ -63,8 +57,8 @@ startScroll(); ...@@ -63,8 +57,8 @@ startScroll();
.item { .item {
display: inline-block; /* 让每个条目水平排列 */ display: inline-block; /* 让每个条目水平排列 */
text-align: left; text-align: left;
padding-left: 100%; padding-left: 500px;
background: gold; color: #fff;
} }
@keyframes scroll-left { @keyframes scroll-left {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册