微信小程序实现轮播图带透明背景标题、且指示点靠右显示

效果图:

wxml:

<swiper indicatorDots="{true}" autoplay="{true}" indicator-active-color="#00ae61">
  <block wx:for="{{imgUrls}}" wx:key="*this">  
    <swiper-item>
      <image src="{{item}}" class="slide-image"/>
      <view class='swipertitle'><text>我是标题啦啦啦</text></view>
    </swiper-item>
  </block>
</swiper>

wxss:

.slide-image{
  width: 100%;/*避免右侧留白*/
}

/*标题背景*/
.swipertitle{
  position: absolute;
  bottom:0;
  padding: 10rpx;
  background-color: rgba(34, 34, 32, 0.308);
  width: 100%;
}

/*文字样式*/
.swipertitle text{
  color: white;
  font-size: 28rpx;
}

/*指示点位置*/
.wx-swiper-dots{
  position:relative;
  left: unset!important;
  right: 0;
}

js:

Page({
  data: {
    imgUrls: [
      'https://images.unsplash.com/photo-1551334787-21e6bd3ab135?w=640',
      'https://images.unsplash.com/photo-1551214012-84f95e060dee?w=640',
      'https://images.unsplash.com/photo-1551446591-142875a901a1?w=640'
    ]
  }
})

 

  • 7
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 14
    评论
评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值