Thu Oct 05 2023

Add Image and Text Above It

CSS106 views
Add Image and Text Above It

File Name: add-img-and-text-above-img.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Add Image and Text Above Image</title>
    <link rel="preconnect" href="https://fonts.googleapis.com" />
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
    <link
      href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;700&display=swap"
      rel="stylesheet"
    />
    <style>
      * {
        margin: 0;
        padding: 0;
        font-family: "Poppins", sans-serif;
      }

      .container {
        width: 100%;
        max-width: 1100px;
        margin: 0 auto;
      }

      .girlImg {
        width: 100%;
        height: 300px;
        object-fit: cover;
        object-position: center;
        border-radius: 50px;
        margin: 10px 0;
      }

      .imgWrapper {
        position: relative;
        display: inline-block;
        width: 100%;
      }

      .imgWrapper h1 {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        color: #fff;
        font-size: 80px;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <p>
        Lorem ipsum dolor, sit amet consectetur adipisicing elit. Quasi sint
        saepe, est qui iusto quo repellat quidem dolor alias dignissimos a ipsa
        laboriosam perferendis dolorem, nam minus praesentium facilis possimus!
      </p>
      <div class="imgWrapper">
        <img
          src="https://cdn.pixabay.com/photo/2018/01/06/09/25/hijab-3064633_960_720.jpg"
          alt="Girl Image"
          width="100%"
          height="100%"
          class="girlImg"
        />
        <h1>Geekboots</h1>
      </div>
      <p>
        Lorem ipsum dolor sit amet consectetur adipisicing elit. Corrupti odit
        qui quos consequuntur nihil dolorum dolorem deserunt repellendus iste,
        aut repudiandae esse. Placeat pariatur eos voluptatibus? Sint aperiam
        repellendus rem?
      </p>
    </div>
  </body>
</html>

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