Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS CSS Layout Basics Positioning Page Content Fixed Positioning

setting the top padding to 68px on the body shifts everything down, including the fixed positioned main header.

Why is this happening? I don't think I missed a step. I thought fixed positioning would have kept the main header at the top but the padding shifted it down, so the first 68px of the page is blank.

1 Answer

Steven Parker
Steven Parker
220,378 Points

By itself, "fixed" just means it will stay where it is (won't scroll). You might have omitted properties to place it specifically at the top:

#fixed-element {
  position: fixed;
  top: 0;   /* put it at the top */
  left: 0;  /* optionally, also put it at the left edge */
}
Luke Kennedy
Luke Kennedy
11,661 Points

Hi Steven,

Thank you for this. I recreate the whole project with my own twist for the CSS Layout basic again I was getting the same error as Elizabeth.

The top:0; (fixed the whole thing). Thank you again!

Luke.

Thank a lot bro, I have the same question before. I forgot the top property.