P粉1455438722023-09-03 14:29:57
Don't hardcode width and height. Use rem or vw/vh (recommended).
.section20 .image, .section20 img { width: 35rem ; // 或者输入相应的rem值 max-width: 100vh ; }
means that the height of this element is equal to 100% of the viewport height.
P粉6045078672023-09-03 09:25:14
Check your selectors.
Specify the img
wrapper using .section20 .image
to stay at 600px
and will not change with max-width: 100%;
while resizing.
Use .image img
instead.
.image img { width: 600px; max-width: 100%; }
<section class='section20'> <figure class="image"> <img src="https://dummyimage.com/600x400/000/fff"> </figure> </section>