<!DOCTYPE html>
<html>
	<head>
		<title>Example Position: fixed</title>
	</head>
  <body>
    <div class="container">
		  <div class="box-orange"></div>
		  <div class="box-blue"></div>
      <p>Scroll down the page</p>
	  </div>
  </body>
</html>
.container { 
  position: relative;
  background: lightgray;
  width: 50%;
  margin: 0 auto;
  height: 1000px;
}

.container p {
  text-align: center;
  font-size: 20px;
}

.box-orange {
  background: orange;
  width: 100px;
  height: 100px;
  position: fixed;
  right: 5px;
}

.box-blue {
  background: lightblue;
  width: 100px;
  height: 100px;
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.