假设小程序的我的中心页面,若是不登陆就获取不到相关信息,而为了获取用户信息则又要单独新增一个页面,又有一些得不偿失,若是读者家的产品愿意的话,这时候读者就能够考虑下笔者这篇文章讲的内容
前提: 强烈推荐使用flex布局方式,float实在遭嫌css
基本结构小程序
<view class="con"> <view class="box"> <button class="btns" bindcontact='contact' open-type='contact'></button> 客服 </view> <view class="box"> <button class="btns" bindgetphonenumber='getPhoneNumber' open-type='getPhoneNumber'></button> 手机 </view> <view class="box"> <button class="btns" bindopensetting='getPhoneNumber' open-type='openSetting'></button> 受权 </view> <view class="box"> <button class="btns" bindgetuserinfo='bindgetuserinfo' open-type='getUserInfo'></button> 用户 </view> </view>
.con{ width: 100%; height: 48px; border: 1px solid blue; display: flex; } .box{ position: relative; width: 100rpx; height: 48px; border: 1px solid red; line-height: 48px; text-align: center; }
.btns{ position: absolute; left: 0; top: 0; width: 100%; height: 100%; opacity: 0; }
若是不放心,能够加个z-index ,这样能够确保被点击的是button自己布局
重要的的样式就是这样。flex
以上。code