top of page
Writer's pictureWeb Coding

Background image with Text Overlay

Updated: Sep 6, 2020

This video will teach you how to add a background image with a text overlay to your website.


HTML Source Code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Background image with text</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div id="content">
        <h1>Hello</h1>
    </div>
</body>
</html>

CSS Source Code

body{
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-image: url(green-plant-leaves-3337202.jpg);
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
}

#content{
    display: flex;
    align-items: center;
    justify-content: center;
    height: 20vh;
    width: 50%;
    background-color: rgba(0, 0, 0, 0.8);
    font-size: 48px;
    color: white;
    text-transform: uppercase;
}

If you found this blog post helpful don’t forget to check out my other projects and if you want more content follow me on

YouTube: https://www.youtube.com/channel/UC2nxqB2usQIS2c8zwVZKWEQ

Instagram: https://www.instagram.com/coding_for_the_web/

Twitter: https://twitter.com/LearnWebCoding

1,152 views

Comments


Commenting has been turned off.
bottom of page