Simple parallax with CSS

https://anhkarppinen.com/simple-parallax-with-css

by anhkarppinen

HTML

<section class="transparent">
  <div class="overlay"></div>
  <div class="overlay-text">
    <div class="container">
      <div class="row">
        <div class="col-md-8 offset-md-2">
            <h1>This is the page title</h1>
        </div><!--col-md-->
      </div><!--row-->
    </div><!--container-->
  </div><!--overlay text-->
</section>
<section class="normal-section">
  <h2>This is a paragraph</h2>
  <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p>
</section>

CSS

html, body {
  padding: 0;
  margin: 0;
}
section.transparent{
  position: relative;
  background: url('https://anhkarppinen.com/wp-content/uploads/2019/08/about.jpg') no-repeat fixed;
  -moz-background-size: cover;
  -o-background-size: cover;
  -webkit-background-size: cover;
  background-size: cover;
  background-position: center;
  height: 500px;
}
.overlay{
  position: absolute;
  background: rgba(0,0,0, 0.3);
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
}
.overlay-text{
  position: absolute;
  color: #fff;
  text-align: center;
  width: 100%;
  top: 50%;
  transform: translateY(-50%);
  -ms-transform: translateY(-50%);
  -moz-transform: translateY(-50%);
  -webkit-transform: translateY(-50%);
}
section.normal-section{
  padding: 30px;
}