css 图片 等比缩放

html

<div
style={{
width: '478px',
height: '361px',
background: '#252a38',
display: '-webkit-flex',
display: 'flex',
WebkitAlignItems: 'center',
alignItems: 'center',
WebkitJustifyContent: 'center',
justifyContent: 'center'
}}
>
<img src="dd.jpg" width=478 heitht=361 style={{
width: 'auto',
height: 'auto',
maxWidth: '100%',
maxHeight: '100%'
}}/>
</div>

结果如下

这样就根据 宽度 自适应 高度 啦

posted @ 2022-10-14 20:30  ifnk  阅读(93)  评论(0编辑  收藏  举报