Simple CSS code snippet for a landing page image

Cover image with unsplash.com

·

1 min read

Cover image trick for a simple landing page, using simple css trick.

    body {
      font-family: Arial, Helvetica, sans-serif;
      background: #333;
      color: #fff;
      margin: 0;
    }

    header {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      text-align: center;
      height: 100vh;
    }

    header:before {
      content: '';
      background: url('https://source.unsplash.com/1600x900/?nature,water') no-repeat center center/cover;
      opacity: 0.6;
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: -1;
    }