场景:
    
     form表单需要button触发提交,但是原生button样式不理想
    
   
    
     
    
   
   
    解决:
   
   
    
     view+css处理样式
    
   
    
     
    
   
    
     代码如下:
    
   
    
     view
    
   
    
    
   
<view class="btnbox" hover-class="btnbox_hover">
    <button class="btn" bindtap="btnClick"></button>
    <view class="text">确定</view>
</view>
    
     
    
   
wxss
    
    
   
.btnbox {
  width: 500rpx;
  height: 100rpx;
  border-radius: 8rpx;
  position: relative;
  overflow: hidden;
  background: #ffb80d;
  color: #fff;
  font-size: 36rpx;
  display: flex;
  justify-content: center;
  align-items: center;
}
.btnbox .btn {
  position: absolute;
  width: 100%;
  height: 100%;
  margin:0;
  padding: 0;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  border: 0;
  opacity: 0;
  background: transparent;
  z-index: 9;
}
.btnbox .text {
  display: block;
  line-height: 1.5;
  text-align: center;
}
.btnbox_hover {
  background: #e6a301
}解决思路:
    
     创建box,让清空样式的button绝对定位,覆盖整个box。
    
   
    
     在box上面创建所需要的样式。
    
   
 
版权声明:本文为blankshsh原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
