我希望容器内的图像垂直对齐在中心。 我在下面试过,都失败了:
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>
答案 0 :(得分:5)
您已设置display: flex
。
const style = { display: 'flex', justifyContent: 'center', alignItems: 'center', width: '..', height: '..'}
<p class="container" style={style}>
<img src={} width={} height={} />
</p>