微信小程序的button按钮设置宽度无效

方法1.

样式中加入!important,即:width: 100% !important;

wxss代码示例

1
2
3
4
5
6
7
8
9
.login-btn {
    font-size16px;
    width100% !important;
    font-weight400;
    color#fff;
    border-radius: 4px;
    border:1px solid rgba(254,50,50,1);
    background:linear-gradient(180deg,rgba(241,94,94,10%,rgba(222,62,62,1100%);
}

  wxml代码示例:

1
<button class="login-btn" bindclick="login">登录</button>

 效果如下图

 

 

 

方法2.

标签内,使用style

wxml代码示例:

1
<button class="login-btn" bindclick="login" style="width:100%">登录</button>

  

方法3.

删除app.json的配置"style": "v2",不过这个不推荐

 

posted @ 2020-10-09 16:11  剑仙6  阅读(2789)  评论(0编辑  收藏  举报
欢迎访问个人网站www.qingchun.在线