0

I want a DIV element fixed but relative to a parent DIV for as the screen resized that fixed DIV will move as the parents moved/resized so when you scroll down the page it will stick to that position. As i know when use position fixed on css, it will be relatively fixed to the entire screen, so the position of that fixed div will be relative to the size of your screen. What i want is that to stick or let the DIV stay to that location of the screen even if you scroll the page but its position will be relative to its parent DIV container. Is there any way to do that on CSS/Javascript/jquery?

Note: The effect should be like position:fixed where the DIV wont move when you scroll the page.

Any answer is greatly appreciated.

4

1 回答 1

0

您可以使用position: absolute. 您应该将 div 嵌套在父 div 中。分配top: 0, left: 0.

是演示。

如果您希望将 div 固定在某个位置,这里是演示。

希望这可以帮助

于 2012-05-24T06:29:49.350 回答