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

实现跑马灯效果图
图片.png
---wxml文件---


  
    
      
      
      {{gundong_text}}
    
  

---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;
}

你可能感兴趣的:(微信小程序之七:跑马灯效果)