数据超过十条开始滚动
<div class="left-block">
<div class="list-block" :class="{ marquee: arr.length > 10 }">
<div class="list" :style="`animation: row ${arr.length * 1}s linear infinite;`">
<div v-for="(item, index) in arr" :key="index" class="dongtai">
<p>{{ item.XXXX }}</p>
</div>
</div>
</div>
</div>
data() {
return {
arr: []
}
},
methods: {
getJointSituationResults() {
apiBase.xxxxx, res => {
this.srr = [
...res.data.content,
...res.data.content
]
})
}
},
.left-block {
position: absolute;
width: 95%;
text-align: center;
color: rgba(255, 255, 255, 0.8);
height: 89%;
.list-block {
height: 100%;
overflow: hidden;
.list {
height: 100%;
overflow: auto;
-ms-overflow-style: none;
overflow: -moz-scrollbars-none;
&::-webkit-scrollbar { //隐藏滚动条
display: none;
}
.dongtai {
width: 100%;
position: relative;
text-align: left;
line-height: 25px;
font-size: 18px;
margin: 10px;
p {
font-size: 18px;
font-family: SourceHanSansCN;
font-weight: 400;
color: #ffffff;
line-height: 20px;
}
}
}
}
//动画 平缓上偏移50%
@keyframes row {
0% {
}
100% {
transform: translateY(-50%);
}
}
.marquee {
position: relative;
.list {
height: initial;
overflow: initial;
// animation: row 15s linear infinite; // 原先是写死的速度,由于数据不固定在html写了
}
.list:hover { // 鼠标悬停停止滚动
animation-play-state: paused !important;
}
}
}