我希望容器内的图像垂直居中对齐。我在下面尝试,都失败了:
display:"inline-block", alignItems:"center", valign:"middle", verticalAlign:"middle",
我的代码如下:
<p style={{display:"inline-block", alignItems:"center", valign:"middle",
verticalAlign:"middle", textAlign:"center", width: "100%", height: "100%" }}>
<img style={{height: "auto", display:"inline-block", valign:"middle",
verticalAlign:"middle", width: "auto", maxWidth: "380px", maxHeight: "200px",
overflow: "hidden" }}
src= "http://icons.iconarchive.com/icons/paomedia/small-n-flat/256/sign-check-icon.png" />
</p>
你必须设置display: flex
。
const style = { display: 'flex', justifyContent: 'center', alignItems: 'center', width: '..', height: '..'}
<p class="container" style={style}>
<img src={} width={} height={} />
</p>