Mon Sep 05 2022

Background-Image property

CSS3472 views

File Name: background-image-property.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Background Image Property</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body {
            background-color: #292929;
        }

        section {
            text-align: center;
            width: 100%;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        div.bgImg {
            width: 300px;
            height: 280px;
            background-color: #fff;
            background-image: url('https://cdn.pixabay.com/photo/2017/11/19/07/30/girl-2961959_960_720.jpg');
            background-size:  cover; /* container; 100px; 100%; auto; */
            background-repeat: repeat /* no-repeat; repeat-x; repeat-y; repeat no-repeat; */;
            background-position: left top /* right bottom; center center; */;
        }
    </style>
</head>
<body>
    <section>
        <div class="bgImg">
            <h1>Welcome</h1>
        </div>
    </section>
</body>
</html>

Result Screenshot(s)

Background-Image propertyWorking Sample0

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.