Thu May 23 2024

Cool Splash Image Effect in CSS

CSS86 views
Cool Splash Image Effect in CSS

File Name: splash-image.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Splash Image</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }

      .container {
        width: 100%;
        height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
        background: #fff;
      }

      .bgImg {
        width: 500px;
        height: 300px;
        background-image: url("https://cdn.pixabay.com/photo/2020/02/15/16/09/loveourplanet-4851331_960_720.jpg");
        background-repeat: no-repeat;
        background-position: center;
        background-size: contain;
        position: relative;
      }

      .bgImg::after {
        position: absolute;
        content: "";
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-image: url("splash.jpg");
        background-position: center;
        background-size: cover;
        background-repeat: no-repeat;
        mix-blend-mode: lighten;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="bgImg"></div>
    </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.