Here is the source code and you can play with jsFiddle, try the auto-scroll button. Here the div tags are placed in the HTML one after another. 67 thoughts on Dont Mess With Tables Pure CSS Fixed-Header Left-Aligned Tables Wickham's HTML & CSS tutorial. Want to know how to fix or freeze the gridview header while scrolling Freeze GridView HeaderLike spreadsheet processors GridView as well has the capability in displaying What methods are usually used for a typical top menu bar (div) to stay in fixed position and in constact view once its top edge hits the browser ceiling viewport, so that the div thereafter overlaps the remaining page contents when scrolled further down? Code. I am trying to design an HTML table where the header will stay at the top of the page when AND ONLY when the user scrolls it out of view. The 'top: ... except that it will not stay fixed when you scroll. On iOS 7 and less yep, the event is only triggered at the end of the scroll. The interesting rule here is the 'position: fixed', that makes the DIV stay fixed on the screen. Not on Chrome for Android, and not on iOS 8 (have to test for the last one) So I'm assuming you want it to stay at the top. Fixed. It contain a simple div #header which we want to freeze at the top. bigspotteddog / ScrollToFixed. Below is the HTML code. Learn how to create a "scroll back to top" button with CSS. No, this is not about using position: fixed by default. it will not move with the page when scrolling. Participate in discussions with other Treehouse members and learn. That way mobile visitors can use it even when theyre not at the bottom of the page. Set the overflow property to scroll: div { width: 150px; height: 150px; overflow: scroll;} Try it Yourself Definition and Usage The overflow property specifies what happens if content overflows an element's box. You could make the scroll top button a little transparent using CSS instead of removing position fixed with a media query. IF so remove the bold code below and let me know if that it what you are after: #container { background-image: url(container.jpg); background-repeat: no-repeat; #header { background: #2e2e2e; width: 100%; z-index: 999; position: fixed; } browsers scrollbar is under my fixed div. As far as I know there is no pure CSS for this task, it uses onscroll to do the job. Bootstrap snippet A BS3 template with large top header, fixed left sidebar. ... response to // the scroll. Basic HTML, CSS & jQuery knowledge is enough to do this work. Once the user scrolls past the header, the navbar fixes to the top. But, unlike absolute, the position is relative to the browser window and not the HTML document. You could potentially use element.scrollTop to see the vertical offset (if you make the tag the element). Removes elements from the flow of the HTML and allows them to be positioned anywhere. How do I position a div so that will flow with the content of the page normally when scrolled down, but stops when at the top of the browser window and hovers over the scrolling page content like a "position: fixed" styled element? Notice the issue metadata stick on top? The HTML. Step 2) Add CSS: To create a fixed top menu, use position:fixed and top:0. This will position the scroll to top button at the top right of the page which we have fixed to stay in this position. Box-2 has position relative and values for top and left applied.