Position fixed div to stick inside the parent

css, html

Solution

You should use `position: absolute` for this.

.container { position: relative; }
.button { position: absolute; top: 0; right: 0; }

JSFiddle example.

`position: fixed` is positioned against the window, not the parent.

Problem

My code goes like this, HTML ``` <div class="container"> <div class="button"></div> </div> ``` CSS ``` .container { position: relative; } .button { position: fixed; top: 0; right: 0; } ``` This is a responsive page and width of the container is dynamically changing when re-sizing the window. I want to stick the `.button` inside the container at top right side even the page is scrolling. But my code shows the `.button` outside the `.container` at top right of the screen. Please help me fix this. Thanks and Regards.

Original source