按钮样式为图标+文字,在使用flex布局写垂直居中时,iphone7手机上文字和图标却没有居中,居左显示。代码以下(已精简):iphone
<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; } }
预期样式:布局
实际样式:flex
给icon和文字外再包一层标签,给外层标签设置flex垂直居中样式,代码以下:spa
<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; } } }