小程序button去除边框,自定义样式

微信小程序button去除边框

微信小程序的button提供了几种系统样式,但在我们开发中一般都用不上,但是有些功能必须只能用button来调用,如分享(open-type="share")

<image class='share-img' src='/assets/btn_share_group.png'/>    
<button class='share-img-button' open-type="share" hover-class="none"></button>

所以我们需要在view上面盖上一个透明的button,来响应事件。
step1.去除button的边框:

.share-img-button{
  border: none;
}
.share-img-button::after{
  border: none
}

step2.去掉button背景:

.share-img-button{
  background: none;
  border: none;
}

step3.盖在要目标view上面:

.share-img{
  width: 96rpx;
  height: 96rpx;
  margin-bottom: 10rpx;
  background: none;
}
.share-img-button{
  position: absolute;
  top: 0rpx;
  width: 96rpx;
  height: 96rpx;
  background: none;
  border: none;
}

Done!

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容