微信小程序左右滚动公告栏效果

<view class='notice-wrap' hidden='{{hideNotice}}'>
  <view class='tongzhitext'>
    <text class="tongzhi-text">{{notice}}</text>
  </view>
  <view bindtap='switchNotice' class="closeView">x</view>
</view>
 data: {
    //初始化数据
    hideNotice: false,
    notice: '',
}
// 点击关闭公告
  switchNotice: function() {
    this.setData({
      hideNotice: true
    })
  },

 

@keyframes remindMessage {
  0% {
    -webkit-transform: translateX(90%);
  }

  100% {
    -webkit-transform: translateX(-180%);
  }
}

.tongzhitext {
  margin-right:80rpx;
  margin-left: 10rpx;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tongzhi-text {
  font-size: 28rpx;
  animation: remindMessage 14s linear infinite;
  width: 100%;
  color: #d09868;
  display: block;
}

.notice-wrap {
  background: #ffebda;
  width: 100%;
  height: 60rpx;
  line-height: 60rpx;
  color: #d09868;
  font-size: 28rpx;
}

.closeView {
  width: 45rpx;
  height: 45rpx;
  line-height: 45rpx;
  position: absolute;
  right: 20rpx;
  top: 5rpx;
  text-align: center;
  font-size: 35rpx;
}

 

效果展示

猜你喜欢

转载自www.cnblogs.com/caoyuna/p/11511130.html