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 trial

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
231,269 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.