小程序 | 实现消息滚动

<view class='notice-board'>
  <view class="scorll-view">
    <view class="notice animation">记住该记住的,忘记该忘记的。改变能改变的,接受不能改变的。</view>
  </view>
</view>
.notice-board {
  width: 100%;
  box-sizing: border-box;
  font-size: 28rpx;
  height: 60rpx;
  background: #888af7;
  display: flex;
  align-items: center;
  position: fixed;
  top: 0;
  z-index: 999;
}


.scorll-view {
  flex: 1;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  color: yellow;
}

.notice{
  transform: translateX(100%);
}

.animation {
  -webkit-animation: rolling 12s linear infinite;
  animation: rolling 12s linear infinite;
}

@-webkit-keyframes rolling {
  0% {
    transform: translateX(100%);
  }

  100% {
    transform: translateX(-170%);
  }
}

@keyframes rolling {
  0% {
    transform: translateX(100%);
  }

  100% {
    transform: translateX(-170%);
  }
}
posted @ 2022-03-14 20:22  槑孒  阅读(93)  评论(0编辑  收藏  举报