TransWikia.com

Сделать чтобы на кнопку не действовал фон

Stack Overflow на русском Asked by Leks on November 15, 2021

.gl {
  width: 300px;
  height: 300px;
  display: inline-block;
  max-width: 300px;
  max-height: 200px;
  background-color: #fff;
  position: relative;
  background-image: url('https://i.ibb.co/QfLmLrT/image.jpg');
  background-repeat: no-repeat;
  background-size: contain;
}

.gl:before {
  content: '';
  position: absolute;
  background-color: rgba(0, 0, 0, .5);
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

a {
  color: red;
  font-size: 30px;
  cursor: pointer;
}
<div class="gl">
  <button>Know More</button>
</div>

One Answer

Вам достаточно переместить кнопку на верхний слой, выше слоя с фоновым изображением и маской:

.gl {
  width: 300px;
  height: 300px;
  display: inline-block;
  max-width: 300px;
  max-height: 200px;
  background-color: #fff;
  position: relative;
  background-image: url("https://i.ibb.co/QfLmLrT/image.jpg");
  background-repeat: no-repeat;
  background-size: contain;
}

.gl::before {
  content: "";
  position: absolute;
  background-color: rgba(0, 0, 0, 0.5);
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

button {
  position: relative;
  z-index: 1000; 
}
<div class="gl">
  <button>Know More</button>
</div>

Answered by Vasily on November 15, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP