This is my code, I want to show hover effect on after element.
#car:after:hover{background:red:}
but this is not working.
This is my code, I want to show hover effect on after element.
#car:after:hover{background:red:}
but this is not working.
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>