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
CHIAMAKA EGBUA
235 PointsHow can I make the width of my header 100% after using fixed position? Width: 100%; isn't working
Fixed positioning
2 Answers
Greg Sargent
3,942 PointsTry 100vw, that will take it the full width of the viewport. % are relative to the parent element.
Christian Puga
3,736 PointsHello , you can't do that with position: fixed, position fixed causes the element not to stretch 100% by default, also remember to put your body margin to 0 value and the padding too.
If your problem keeps you should put the code so we can try and help you
GL
Dane Parchment
Treehouse Moderator 11,077 PointsHello , you can't do that with position: fixed, position fixed causes the element not to stretch 100% by default
Unless I am misreading your comment, you can definitely stretch a fixed element by at least 100% and the poster, specified that they used width: 100% already. Unless we see their code, it won't really be evident what is causing the fixed item to not cover 100% of the width.
Dane Parchment
Treehouse Moderator 11,077 PointsDane Parchment
Treehouse Moderator 11,077 PointsCan you show us your code or at the very least an image of the 100% width not working, their could be many reasons for that. For example the body has a margin and padding, setting those both to 0 should allow elements to take up the full width of the screen.