Hero Image: Background Image

In this example below you will see how to do a Hero Image: Background Image with some HTML / CSS and Javascript

Read the article here: http://praliedutzel.com/a-guide-to-hero-images/

Thumbnail
This awesome code was written by praliedutzel, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright praliedutzel ©
  • HTML
  • CSS
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>Hero Image: Background Image</title>
  
  
  
      <link rel="stylesheet" href="css/style.css">

  
</head>

<body>

  <header class="header">
  <h1 class="header__title">A Guide to Hero Images: Background Image</h1>
  <a href="http://praliedutzel.com/a-guide-to-hero-images/" target="_blank">Read the Article</a>
</header>

<section class="hero">
  <div class="hero__content">
    <h2>Hero Images</h2>
    <p>Can be created with a background-image in CSS.</p>
  </div>
</section>
  
  

</body>

</html>

/*Downloaded from https://www.codeseek.co/praliedutzel/hero-image-background-image-dGPOKM */
.hero {
  background-color: #fff;
  background-image: url("http://placehold.it/500x300");
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
}

.hero__content {
  padding: 10rem 3rem;
  text-align: left;
}

body {
  background-color: #f9f9f9;
  margin: 0;
  padding: 0;
  font-family: "Open Sans", Helvetica Neue, Helvetica, Arial, sans-serif;
  text-align: center;
}

.header {
  background-color: #232439;
  padding: 4rem 2rem;
  text-align: center;
}
.header a {
  margin-top: 1rem;
  display: block;
  color: #6ddce5;
  font-size: 0.85rem;
  text-decoration: none;
}

.header__title {
  margin: 0;
  color: #fff;
  font-weight: 300;
}

Comments