s

Background



Testing using a background image in a Hugo website

You can define a featured_image in the front matter of a post. This is not quite working for me yet so I am using the CSS route.

<w3schools.com> has a section on using a background-image in the CSS tutorial.

<style> 
#example1 {
  background-image: url(img_flwr.gif), url(paper.gif);
  background-position: right bottom, left top;
  background-repeat: no-repeat, repeat;
  padding: 15px;
}
</style>

<div id="example1"></div>

Using a hero image:

.hero-image {
  background: url(img_man.jpg) no-repeat center; 
  background-size: cover;
  height: 500px;
  position: relative;
}

.hero-text {
  text-align: center;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
}
<div class="hero-image">
  <div class="hero-text">
    <h1 style="font-size:50px">I am John Doe</h1>
    <h3>And I'm a Photographer</h3>
    <button>Hire me</button>
  </div>
</div>
Background screenshot

Tech used:
  • JavaScript
  • CSS
  • HTML