Skip to content

Instantly share code, notes, and snippets.

@Tiny-Giant
Created August 15, 2015 04:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tiny-Giant/eb63379e02a848bdfdb9 to your computer and use it in GitHub Desktop.
Save Tiny-Giant/eb63379e02a848bdfdb9 to your computer and use it in GitHub Desktop.

I'm trying to create a page with a fixed div above the main div. The main div should be below the fixed div but instead it overlaps the fixed div.

Adding margin-top positions the main div below the fixed div but, it also clips the same amount off of the bottom of the page.

What am I doing wrong?

Live Demo

body {
  background-color: #00FFFF;
}
.fixed {
  width: 100%;
  position: fixed; 
  background-color: #C0C0C0;
}
.main {
  background-color: #FFFFFF;
}
.expand {
  height: 800px;
}
<div class="fixed">
  fixed div line 1<br />
  fixed div line 2<br />
  fixed div line 3<br />
</div>
<div class="main">
  <div class="expand"></div> <!-- For demo purposes only -->
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment