找回密码
 立即注册
搜索
查看: 185|回复: 0

微信小程序快速使其他元素具有button特性

[复制链接]

581

主题

110

回帖

4066

积分

管理员

积分
4066

众神之神

发表于 2025-12-18 10:08:45 | 显示全部楼层 |阅读模式
小程序用些功能接口必须要用button才能触发,而button的默认样式修改起来很麻烦,可以快速使其他元素具有button特性。


其他元素,作为button的父层出现,“position: relative;”
  1. <view class="content_list" style="position: relative;">
  2.                                                 <image class="content_list_img" src="/static/images/haoyou.png" mode="aspectFill"></image>
  3.                                                 <text class="content_list_text">好友/群</text>
  4.                                                 <button
  5.                                                         style="
  6.                                                         position: absolute;
  7.                                         top: 0;
  8.                                         left: 0;
  9.                                         height: 100rpx;
  10.                                         width: 100%;
  11.                                         opacity: 0;
  12.                                                         "
  13.                                                        
  14.                                                         open-type="share"
  15.                                                 >
  16.                                                 </button>
  17.                                         </view>
复制代码



button的核心样式,所包裹的父级是:“position: relative;”
  1. <button
  2. style="
  3. position: absolute;
  4. top: 0;
  5. left: 0;
  6. height: 100rpx;
  7. width: 100%;
  8. opacity: 0;
  9. "
  10. >
  11. </button>
复制代码


您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|十三博客 ( 鲁ICP备2023000528号 )

GMT+8, 2026-6-1 17:24 , Processed in 0.067566 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表