skip to Main Content

I’ve been asking Chat GPT about this and it tells me that the Content div should be placed below the Header div, which is what I want.

.header {
  position: fixed;
}
<div class="header">Header</div>
<div class="content">Content</div>

But both locally and in several online HTML editors, the Content div is placed on top of the Header div.

Is Chat GPT stupid, or am I stupid (probably)?

2

Answers


  1. Its just behind your header. See the changes.

    .header {
      background: black;
      color: white;
    }
    
    .content {
      margin-top: 30px;
      background: yellow;
      color: black;
    }
    <div class="header">
      <div>Header</div>
    </div>
    
    <div class="content">Content</div>
    Login or Signup to reply.
  2. Positioning a DiV below a fixed Div is done by making its position absolute.
    I hope you got the answer by now.

    .header {
      background: black;
      color: white;
      position: fixed;
    }
    
    .content {
      top: 50px;
      background: yellow;
      color: black;
      position: absolute;
    }
    <div class="header">Header</div>
    
    <div class="content">Content</div>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search