微信公众号开发

微信小程序:如何让按钮button中的文字居中

本文主要是介绍微信小程序:如何让按钮button中的文字居中,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

效果

wxml

<button type="primary" form-type='submit'>登录</button>

wxss

添加如下样式:

button[type="primary"] {
    display:flex;
    align-items: center;
    justify-content: center;
}

所有样式如下:

button[type="primary"] {
    display:flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    line-height: 40px;
    font-size: 36rpx;
    text-align: center;
    background-color: #007AFF !important;
    margin-top: 20px;
    margin-bottom: 20px;
    color: #FFFFFF;
    border-radius: 10px;
}

 效果如下

 

这篇关于微信小程序:如何让按钮button中的文字居中的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!