HTML CSS examples for CSS Layout:Relative Position
make a div inside a relative positioned keep position to its container when scrolling
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <!-- ww w .ja va 2 s . com--> <body> <div id="container" style="position:relative; width:200px; height:300px; overflow: auto;"> <div style="position:absolute; top:10px; left:10px; width: 100px;"> <div id="absoluteinner" style="position:fixed; width:100px; height:100px; background-color:red;"></div> </div> <div id="staticinner" style="width:100px; height:800px; background-color:purple;"></div> </div> </body> </html>