Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
}
.top-container {
  background-color: #f1f1f1;
  padding: 30px;
  text-align: center;
}
.header {
  padding: 10px 16px;
  background: #555;
  color: #f1f1f1;
}
.content {
  padding: 16px;
}
.sticky {
  position: fixed;
  top: 0;
  width: 100%;
}
.sticky + .content {
  padding-top: 102px;
}
</style>
</head>
<body>
<div class="top-container">
  <h1>Scroll Down</h1>
  <p>Scroll down to see the sticky effect.</p>
</div>
<div class="header" id="myHeader">
  <h2>My Header</h2>
</div>