Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialNabil Arkate
Courses Plus Student 9,940 PointsFixed header
Hi, How to fix the header on the top while scrolling the page using css.
1 Answer
Steven Parker
229,732 PointsThe easiest way is using the "fixed" value for the "position" property.
You will probably also need to add a margin to the top of the page to push everything else down so it can be seen, since the header size will no longer be included in positioning calculations.
header { position: fixed; top: 0; }
body { margin-top: 100px; } /* make size large enough for header */
Gustavo Winter
Courses Plus Student 27,382 PointsGustavo Winter
Courses Plus Student 27,382 PointsCheck this page Here
Position: Fixed is what you are looking for, if it doesnt help you, i can link a video of treehouse where they Approach this. Check this code