Fluid width fixed position

后端 未结 7 1770
清酒与你
清酒与你 2021-02-18 22:32

Imagine:

Where:

  • .outer is
7条回答
  •  再見小時候
    2021-02-18 22:57

    position: fixed is always relative to the window/browser, thus it cannot be used to solve your problem. Fixed positioning removes the element from the natural order of the DOM, and thus does not remain within your outer div anymore, hence why it takes the full width of the browser and not of your container. What you need to use is position: absolute to place .inner relative to .outer. You'll be able to position your element as well as have its width be contained by the .outer div.

提交回复
热议问题