Vue 跑马灯效果
vue简单的跑马灯效果,直接封装的组件,引入就能用。
<template>
<div class="block">
<h3 class="h3_title">
特别提醒
</h3>
<p class="words" ref="words" :text="content" >
{{content}}
</p>
</div>
</template>
<script>
export default {
name: 'NoticeBar',
props: {
content: {
type: String,
default: ''
},
},
};
</script>
<style scoped="scoped">
.mg_Top{
color: #FFF797;
}
.h3_title{
position: absolute;
background: #ffffff;
display: block;
z-index: 9;
font-family: '微软雅黑';
}
* {
margin:0;padding: 0;
font-size: 13px;
color:#606266;
}
.block {
width: 100%;
/* background-color: #65b4ae; */
white-space: nowrap;
overflow: hidden;
}
.words {
position: relative;
width: fit-content;
animation:move 100s linear infinite;
padding-left:50px;
}
.words::after{
position: absolute;
right:-100%;
content:attr(text);
}
@keyframes move {
0% {
transform: translateX(0);
}
100% {
transform: translateX(-100%);
}
}
</style>

浙公网安备 33010602011771号