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…

1 year ago

Merrimu Reservoir drone images

Merrimu Reservoir from drone. Click images to view larger.

1 year ago

FTP getting array of file details such as size using PHP

Using FTP and PHP to get an array of file details such as size and…

2 years ago

Creating Laravel form requests

Creating and using Laravel form requests to create cleaner code, separation and reusability for your…

2 years ago

Improving the default Laravel login and register views

Improving the default Laravel login and register views in such a simple manner but making…

2 years ago

Laravel validation for checking if value exists in the database

Laravel validation for checking if a field value exists in the database. The validation rule…

2 years ago