Elements whose display is none cannot obtain width and height through offsetWidth and offsetHeight (not participating in CSS rendering),
Solution: You can set the width and height by using the inline style style on the element whose display is none, and get it through style.width and style.height,
Note: Styles cannot be written in css files. Otherwise you can't get it