Div height equal to another div max-height

前端 未结 4 1391
孤街浪徒
孤街浪徒 2021-01-16 03:49

I have 3 divs:

  • Div
4条回答
  •  爱一瞬间的悲伤
    2021-01-16 04:21

    If you set both div "one" and div "two" to have a height of 100%, you can control the height of both of them via the style of the outer div, and you are guaranteed that they always have the same height.

    If you always want div "two" to be as high as div "one" or shorter, here's some JavaScript code that may help you:

    document.getElementById("two").style.maxHeight = document.getElementById("one").style.height;
    

提交回复
热议问题