CSS position:fixed inside a positioned element

后端 未结 8 1194
庸人自扰
庸人自扰 2020-12-13 08:15

I have a positioned div whose content can be too long so scrollbars appear (overflow:auto set). It functions as a dialog box in an ajax app. I want to fix a clo

8条回答
  •  南方客
    南方客 (楼主)
    2020-12-13 08:52

    Position:fixed gives an absolute position regarding the BROWSER window. so of course it goes there.

    While position:absolute refers to the parent element, so if you place your

    button inside the <div> of the container, it should position where you meant it to be. Something like

    EDIT: thanks to @Sotiris, who has a point, solution can be achieved using a position:fixed and a margin-left. Like this: http://jsfiddle.net/NeK4k/

提交回复
热议问题