Answers for "how to add black overlay on background image in css"

CSS
2

how to put a black overlay on a photo css

.header {
  background: rgba(0, 0, 0, 0.5); /* Black color with 50% alpha/opacity */
}
Posted by: Guest on December-19-2020
0

black background overlay filter | black overlay for image css

Exp:
<header>
  <img src="https://picsum.photos/id/1036/4608/3072" alt="Placeholder-Image">
  <section>
    <h1>Heading</h1>
    <h2>Just another tech blog.</h2>
    <button>Read more.</button>
  </section>
</header>

Add This Css:
header img {
  width: 100vw;
  height: 100vh;
  object-fit: cover;
  filter: brightness(.4);
}


section {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-family: 'Roboto', sans-serif;
}
Posted by: Guest on March-06-2022

Code answers related to "how to add black overlay on background image in css"

Browse Popular Code Answers by Language