美文网首页微信小程序开发
微信小程序之七:跑马灯效果

微信小程序之七:跑马灯效果

作者: ZIM东东 | 来源:发表于2018-11-21 13:20 被阅读11次
实现跑马灯效果图
图片.png
---wxml文件---
<!--跑马灯中的文字信息字段:gundong_text-->
<view wx:if='{{gundong_text}}' class="marquee_container" style="--marqueeWidth--:-12em">
  <view class='marquee_text'>
    <view class='hengxianggundong'>
      <image class='gundong_image' mode='aspectFit' src='../../image/laba.png'></image>
      <view class='triangle-left'></view>
      <view class="gundong_textView weui-zimFont9">{{gundong_text}}</view>
    </view>
  </view>
</view>
---wxss文件---
/* 跑马灯样式 */
@keyframes around {
  from {
    margin-left: 100%;
  }
  to {
    /* var接受传入的变量 */
    margin-left: var(--marqueeWidth--);
  }
}
.marquee_container {
  position: absolute;
  top: 120rpx;
  width: 100%;
  height: 60rpx;
  line-height: 60rpx;
  z-index: 1200;
}
.marquee_container:hover {
  /* 不起作用 */
  animation-play-state: paused;
}
.marquee_text {
  display: inline-block;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  white-space: nowrap;
  animation-name: around;
  animation-duration: 10s; /*过渡时间*/
  animation-iteration-count: infinite;
  animation-timing-function: linear;
}
.hengxianggundong {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
}
.gundong_image {
  background-color: rgba(0, 0, 0, 0.6);
  width: 50rpx;
  height: 50rpx;
  border-radius: 50%;
  margin-right: 20rpx;
}
.triangle-left {
  width: 0;
  height: 0;
  border-right: 10rpx solid rgba(0, 0, 0, 0.8);
  border-bottom: 10rpx solid rgba(0, 0, 0, 0);
  border-top: 10rpx solid rgba(0, 0, 0, 0);
}
.gundong_textView {
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  padding-left: 20rpx;
  padding-right: 20rpx;
  border-radius: 10rpx;
}

全部文章地址:www.freefook.com

相关文章

网友评论

    本文标题:微信小程序之七:跑马灯效果

    本文链接:https://www.haomeiwen.com/subject/jozqqqtx.html