-1

This is my code, I want to show hover effect on after element.

 #car:after:hover{background:red:}

but this is not working.

Therichpost
  • 1,759
  • 2
  • 14
  • 19

1 Answers1

2

check out this demo below. I think you are missing content property.

the Red div is created using :after and changes its color on hover.

the selector:after:hover won't work.

.car {
  position: relative;
  width: 100px;
  height: 100px;
  background: yellow;
}

.car:hover {
  background: skyblue;
}

.car:after {
  content: '';
  width: 50px;
  height: 50px;
  position: absolute;
  right: 0;
  bottom: 0;
  background: green;
}

.car:hover:after {
  background: red;
}
<div class="car"></div>
Deepak Yadav
  • 6,804
  • 5
  • 31
  • 49