How can I get an absolutely-positioned div to extend outside its relativley-positioned parent, which has overflow: auto?

前端 未结 8 771
栀梦
栀梦 2021-02-01 14:53

I have a relatively -positioned div, which has overflow: auto set. Inside that, I have a div which acts as a sort of drop-down menu. I want the drop-down div to e

8条回答
  •  青春惊慌失措
    2021-02-01 14:59

    That's impossible. If you set overflow:auto on the parent DIV, that locks any child DIV from breaking out of the content box.

    You could try and fiddle with z-index values, but that may cause you to go blind in the left eye.

    An idea would be to wrap the parent DIV with another DIV so that the DIV you want to pop out will be positioned according to the grandparent DIV. But that way will give you carpal tunnel and won't work either because you would have to know where in the flow of the parent DIV you want the child DIV to be.

提交回复
热议问题