干货来了!!!!
微信小程序跑马灯的效果,不说了,上来就是cv操作;
html
<!--跑马灯 -->
<view class="marquee_container" style="--marqueeWidth--:-12em">
<view class="wel_notice_msg">公告:</view>
<view class="marquee_text">{{notice}}</view>
</view>
<!--跑马灯-->
/*首页跑马灯效果*/
.wel_notice_msg{
height: 50rpx;
background-color: #fe4655;
position: absolute;
padding-left: 5rpx;
color: #fff;
/* background-color: aquamarine; */
}
@keyframes around {
from {
margin-left: 100%;
}
to {
/* var接受传入的变量 */
margin-left: var(--marqueeWidth--);
}
}
.marquee_container{
float: left;
background-color: #fe4655;
height: 50rpx;
line-height: 44rpx;
position: relative;
width: 100%;
margin-top:0rpx;
}
.marquee_container:hover{
/* 不起作用 */
animation-play-state: paused;
}
.marquee_text{
color:#fff;
font-size: 28rpx;
display: inline-block;
white-space: nowrap;
animation-name: around;
animation-duration: 10s; /*过渡时间*/
animation-iteration-count: infinite;
animation-timing-function:linear;
}
/*首页跑马灯效果*/
感觉有用的老哥留个关注不迷路!!!