How to make the height of the div change with the height of the background image?

the outermost div has a background image. I want the width of the background image to be 100%, that is, the width of the entire screen. How can I do this? the height of the outermost div is the height of the background picture. You can scroll the phone screen to see the whole background picture.
Thank you ~

Css
Mar.14,2021

if you don't want to calculate through JS,
you can extend the height of the div by adding the img tag in the div.
then set the img inside to transparent, so that the height of the div can be as high as the height of the picture


fixed-scale picture: the width is 100%, which is equal to 100vW. According to the aspect ratio of the picture, for example, the current aspect ratio is 1 wide to 2 high, then the height is set to height:200vw;

.

Random picture: please directly use the img tag, give a 100% location or layering, ha ha hiccup

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b34ace-4d5cf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b34ace-4d5cf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?