<template>
<div class="notice">
<div class="notice-container">
<div class="notice-bar">
<div class="bar_text" v-for="(item,index) in noticeList" :key="index" >
{{item}}
</div>
</div>
</div>
</div>
</template>
<script lang="ts" setup>
const noticeList = [
'你好!!!',
]
</script>
<style >
.notice{
display: flex;
background: #4073fa;
margin-top: 10px;
padding: 2px 5px;
}
.notice-container{
display: flex;
width:calc(100% - 30px);
height: 25px;
overflow: hidden;
margin-left: 5px;
}
.notice-bar{
font-size: 15px;
margin-left: 10px;
display: flex;
animation: move 15s linear infinite;
line-height: 20px;
color: #f5f6f7;
.bar_text{
width: max-content;
min-width: 100px;
}
}
@keyframes move{
0% {
transform: translateX(400%);
}
100%{
transform: translateX(-100%);
}
}
</style>
播放速度和位移,根据自己需求调整,效果图: