2

I have a span which is circular black in color,and it has a background image as a property. I want the span to have an opacity of 0.75 but the background image should have opacity 1. On hover the opacity of background image and span should be 1.

.left-arrow-black-bar {
  display: inline-block;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #000;
  text-align: center;
  opacity: 0.75;
  background-image: url('https://image.ibb.co/bJD73R/arrow_left.png');
  background-repeat: no-repeat;
  background-position: center;
  background-size: 10px 18px;
}

.left-arrow-black-bar:hover {
  opacity: 1;
}
<span class="left-arrow-black-bar"></span>
Carl Binalla
  • 5,393
  • 5
  • 27
  • 46
Harpreet Chawla
  • 171
  • 2
  • 15

1 Answers1

2

Use rgba instead of hex:

.left-arrow-black-bar{
  display: inline-block;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.75);
  text-align: center;
  background-image: url('https://image.ibb.co/bJD73R/arrow_left.png');
  background-repeat: no-repeat;
  background-position: center; 
  background-size: 10px 18px;
}
.left-arrow-black-bar:hover{
  background-color: rgba(0, 0, 0, 1);
}
<span class="left-arrow-black-bar"></span>
Huelfe
  • 1,776
  • 16
  • 25