问题描述
按钮样式为图标+文字,在使用flex布局写垂直居中时,iphone7手机上文字和图标却没有居中,居左显示。代码如下(已精简):
<button>
<img src="./refresh.png" alt />
{{ confirmButtonText }}
</button>
...
button {
display: flex;
align-items: center;
justify-content: center;
img {
width: 36px;
height: 36px;
display: inline-block;
}
}
预期样式:

实际样式:

解决方式
给icon和文字外再包一层标签,给外层标签设置flex垂直居中样式,代码如下:
<button>
<span class="wrap">
<img src="./refresh.png" alt />
{{ confirmButtonText }}
</span>
</button>
...
button {
display: flex;
align-items: center;
justify-content: center;
.wrap {
img {
width: 36px;
height: 36px;
display: inline-block;
}
}
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

评论(0)