0

I'm trying to overlay an h1 over an image, using Grid; for better contrast, I thought about using filter:brightness(80%) on the image, which, unfortunately, removes the h1 altogether.

Is there any workaround to this? ( without pasting in image URLs in CSS) (filter is commented for you to apply and see)

body{
  background: grey;
  margin: 10px;
  color: white;
  text-align: center;
}
img{
  max-width: 100%;
  max-height: 100%;
}
.gridcontainer{
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-gap: 10px;
  max-width: 100vw;
  align-items: center;
}

.griditem{
  background: black;
}

.headingcover{
  grid-column: 1/3;
  grid-row: 1/2;
  /* filter: brightness(80%); */
}
h1{
  grid-column: 1/3;
  grid-row: 1/2;
}
  <div class="gridcontainer">
    <img src="https://source.unsplash.com/7TGVEgcTKlY" alt="" class="headingcover">
    <div class="griditem b">b</div>
    <div class="griditem c">c</div>
    <div class="griditem d">d</div>
    <h1>Foxy</h1>
  </div>
TylerH
  • 20,799
  • 66
  • 75
  • 101
Lienleaf
  • 21
  • 3

2 Answers2

0

other than filter you can use text-shadow property of css for better contrast.

0

Try adding a z-index to your h1 to put it above your filter in the element stack.

h1 { 
    grid-column: 1/3; 
    grid-row: 1/2;
    z-index: 10;
}
Coffee bean
  • 1,474
  • 15
  • 27