view标签文本垂直居中的问题
发布于 5 年前 作者 jun37 7363 次浏览 来自 问答

不管是flex布局还是line-height布局,view在真机上都不能垂直居中,而button可以。但是官方button默认样式又一堆,能不能把view兼容性改好?

2 回复

<!--  pages/login/login.wxml -->

<view class=‘view-table’ >

  <view class=‘view-cell’ >

    <label>帐号</label>

    <input type=‘text’ placeholder=‘请输入会员帐号’ ></input>

    <label>密码</label>

    <input type=‘password’ placeholder=‘请输入登录密码’ ></input>

    <button>登录</button>

  </view>

</view>

/* pages/login/login.wxss */

view{

  border: 0px solid red;

  width:97%;

  height:1200rpx;

  padding: auto;

  margin: auto;

  text-align: center;

  vertical-align: middle;

}

.view-table{

  display:table;

}

.view-cell{

  display:table-cell;

  width:800rpx;

}

input{

  border: 1px solid red;

  margin:30px;

  height:60px;

}

设置个高度然后line-height写一样可以么?

回到顶部