P粉1455438722023-09-03 14:29:57
不要硬编码宽度和高度。使用rem或vw/vh(推荐)。
.section20 .image, .section20 img { width: 35rem ; // 或者输入相应的rem值 max-width: 100vh ; }
表示此元素的高度等于视口高度的100%。
P粉6045078672023-09-03 09:25:14
检查你的选择器。
使用.section20 .image
指定img
包装器保持在600px
,并且不会随max-width: 100%;
而调整大小。
改用.image img
。
.image img { width: 600px; max-width: 100%; }
<section class='section20'> <figure class="image"> <img src="https://dummyimage.com/600x400/000/fff"> </figure> </section>