# Position:fixed question

**URL:** <https://forum.freecodecamp.org/t/position-fixed-question/491765>\
**Category:** Curriculum Help\
**Tags:** html, css\
**Created:** [January 9, 2022, 10:36am UTC](https://forum.freecodecamp.org/t/position-fixed-question/491765 "2022-01-09T10:36:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucretat](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lucretat/32/371018_2.png) [@lucretat](https://forum.freecodecamp.org/u/lucretat)\
**Post date:** [January 9, 2022, 10:36am UTC](https://forum.freecodecamp.org/t/position-fixed-question/491765/1 "2022-01-09T10:36:25Z")

</div>

Hello,

I’m working on the Landing page project and I don’t understand why the header element does not take up the whole width of the screen. By trial and error I now know the positon:fixed is causing this (if removed, it is OK).

Can you help me understand please? Thanks a lot!

CodePen: [https://codepen.io/Dr-O-Dr/pen/yLzqxzL](https://codepen.io/Dr-O-Dr/pen/yLzqxzL)

---

<div class="post-metadata">

**Author:** ![HawksSpawn](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/hawksspawn/32/237096_2.png) [@HawksSpawn](https://forum.freecodecamp.org/u/HawksSpawn)\
**Post date:** [January 9, 2022, 11:04am UTC](https://forum.freecodecamp.org/t/position-fixed-question/491765/2 "2022-01-09T11:04:15Z")

</div>

Hi @lucretat and welcome to the forum!!!  
With the `position` property set to `fixed`, to take up the whole width of the screen you need to set `width` property to `100%`.

```auto
.class {
  position: fixed;
  top: 0;
  width: 100%;
}

```

I link, in my opinion, the complete answer about your question.

> <https://stackoverflow.com/questions/16442457/why-does-fixed-positioning-alter-the-width-of-an-element/16442617#16442617>

👋

---

<div class="post-metadata">

**Author:** ![lucretat](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lucretat/32/371018_2.png) [@lucretat](https://forum.freecodecamp.org/u/lucretat)\
**Post date:** [January 9, 2022, 12:41pm UTC](https://forum.freecodecamp.org/t/position-fixed-question/491765/3 "2022-01-09T12:41:34Z")

</div>

Thanks, I figured that 100% width as well and read the answer. However, still not completely clear on the topic… The fixed element (if width is not specified) should take up the width of the viewport, right? The viewport is the whole screen size, is it not? So I should see the header having the width of the window, correct? However, I see this instead:

 ![image](https://global.discourse-cdn.com/freecodecamp/original/3X/d/0/d07748ee76fdf918696af01de82e691f5d3dbc0c.png)

---

<div class="post-metadata">

**Author:** ![lucretat](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lucretat/32/371018_2.png) [@lucretat](https://forum.freecodecamp.org/u/lucretat)\
**Post date:** [January 9, 2022, 12:42pm UTC](https://forum.freecodecamp.org/t/position-fixed-question/491765/4 "2022-01-09T12:42:11Z")

</div>

I also use the dev tools on the original project page (the assignment) and there is no width:100% in the CSS:

 ![image](https://global.discourse-cdn.com/freecodecamp/original/3X/6/7/67c8aebcdf35f52c26773aafe768c0d7e846028e.png)

Sorry if my questions are lame 😁 and thanks for your time!

---

<div class="post-metadata">

**Author:** ![HawksSpawn](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/hawksspawn/32/237096_2.png) [@HawksSpawn](https://forum.freecodecamp.org/u/HawksSpawn)\
**Post date:** [January 10, 2022, 1:00pm UTC](https://forum.freecodecamp.org/t/position-fixed-question/491765/5 "2022-01-10T13:00:31Z")

</div>

Hi @lucretat,  
I really don’t know why, I don’t have this problem as you can see in the image.

 ![Screenshot (79)](https://global.discourse-cdn.com/freecodecamp/original/3X/9/7/972e23d0232d78b950c7fdf694ef5c551a576141.png)

Your browser zoom is set to 100%?

---

<div class="post-metadata">

**Author:** ![lucretat](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lucretat/32/371018_2.png) [@lucretat](https://forum.freecodecamp.org/u/lucretat)\
**Post date:** [January 11, 2022, 2:48pm UTC](https://forum.freecodecamp.org/t/position-fixed-question/491765/6 "2022-01-11T14:48:20Z")

</div>

I was adjusting in to width 100% after, so maybe you’re seeing that? My browser zoom is OK, everything else is looking right.

Don’t worry about it, I will just go with 100% width property 😉

Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [July 13, 2022, 2:48am UTC](https://forum.freecodecamp.org/t/position-fixed-question/491765/7 "2022-07-13T02:48:23Z")

</div>

Closed on July 13, 2022, 2:48am UTC

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
