height:1000px.<html lang="ja">
<body>
<div style="background-image:url(./test.png);background-repeat:no-repeat;background-size:cover;max-width:400px;">/div>
</body>
</html>
If the aspect ratio of the image is constant, you can simply specify the aspect-ratio property.
If the aspect ratio is not constant, I don't think CSS alone can do it.Load the image in Image() and update the height properties of the naturalWidth element calculated from naturalHeight.
© 2025 OneMinuteCode. All rights reserved.