Categories: Development

Full screen image background with text overlay

How to easily get a responsive full screen image background with text overlay in HTML such as this:

The method shown here uses Bootstrap, you could however do it vanilla CSS with some tweaking.

The image was taken from here and you can view a working CodePen here.

The HTML code:

<div class='image-background'>
  <div class='container h-100'>
    <div class='row h-100 align-items-center'>
      <div class='col-12 text-center'>
        <h1 class='display-2'>This is LA</h1>
        <p class='lead'>Image taken from /r/wallpapers</p>
      </div>
    </div>
  </div>
</div>

CSS code:

body {
  color: white;
}
.image-background {
  height: 100vh;
  min-height: 500px;
  background-image: url("https://i.redd.it/9qgaiif7gum31.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

Thats it!

Share

Recent Posts

Kennington reservoir drained drone images

A drained and empty Kennington reservoir images from a drone in early July 2024. The…

2 years ago

Merrimu Reservoir drone images

Merrimu Reservoir from drone. Click images to view larger.

2 years ago

Early September spring shots

Some early September spring shots from a bushwalk, It is still too early for wildflowers.

3 years ago

Cloning an NVMe to SK Hynix Platinum P41 NVMe

I recently needed to clone over a smaller NVMe to a 2TB SK Hynix Platinum…

3 years ago

Using Laravel’s deleteDirectory to delete folders and their contents

If you ever needed a simple solution in Laravel to delete an entire directory and…

3 years ago

How to allow only 1 user to register in a Laravel application

How to enforce only one user to register or be registered in a Laravel web…

3 years ago