CSS position:fixed inside a positioned element

后端 未结 8 1201
庸人自扰
庸人自扰 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:44

    If your close button is going to be text, this works very well for me:

    #close {
      position: fixed;
      width: 70%; /* the width of the parent */
      text-align: right;
    }
    #close span {
      cursor: pointer;
    }
    

    Then your HTML can just be:

    X

提交回复
热议问题