0

I've figured out that the floating elements are what is causing the problem.

Here is my code

#header {
  position: sticky;
}

#main {
  width: 100%;
}

#content {
  width: 50%;
  float: left;
  height: 800px;
  box-sizing: border-box;
  border: solid red;
}
<body>
  <h1 id="header">Header</h1>
  <div id="main">
    <p id="content">words</p>
    <p id="content">words</p>
  </div>
</body>

On my site, I am using the RWD column design by W3 if that is relevant. It just formats the width and floats anything with the specific class.

1 Answers1

0

After using float, you have to use clear

body {
  height: 100%;
}

#header {
  position: sticky;
  top: 0;
}

#main {
  width: 100%;
}

#content {
  width: 50%;
  float: left;
  height: 800px;
  box-sizing: border-box;
  border: solid red;
}

.clear-fix {
  clear: both;
}
<body>
  <h1 id="header">Header</h1>
  <div id="main">
    <p id="content">words</p>
    <p id="content">words</p>
    <div class="clear-fix"></div>
  </div>
</body>
Aleksandr Belugin
  • 2,149
  • 1
  • 13
  • 19