Later I found that if the div style is set to a specific height, it can behave normally regardless of IE or FF.
But this height is not fixed, but will change depending on the content of the adjacent div. In the end, I had to use JavaScript to capture the height of the relevant div when loading, assign it to the specified div style, and finally see what I wanted.
The specific script is as follows:
window.onload=function(){
document.getElementById('bg').style.height=document.getElementById('mydiv') .offsetHeight 'px';
}
"bg" is the div whose height you want to change, and "mydiv" is the div you want to refer to.
The last unit "px" must be added, otherwise it will not be recognized under ff.
There is still a problem. I saw someone said that the offsetHeight attribute is no longer supported in IE7. I have not tried it specifically. If this is the case, it will have to be blank under IE7.