I want to start a transition when I click on a div. Currently my transition happens only when using with css active. I want this transition to happen when I click on this div. How can i do that? I'm using reactjs and i think it should be done using states. But I cannot figure out how to do this.
I have done something like this but it is not working the way i intended. I have done something similar to this when i had only :active class. But in this instance i have :before and :active:before.
I want to know how to change css via states which has :before property.
i found this link but was not helpful
ReactJs adding active class to button
This is my approach
<div className='vote_card_hover' style={{transform:this.state.toggle? 'translate(-50%, -50%) scale(1)':''}}>
My code
<div className='vote_card_hover'>
<a>Test</a>
</div>
my CSS
.vote_card_hover {
position: absolute;
width: 100px;
height:100px;
transition: .3s ease;
background-color: 'red'
}
.vote_card_hover:before {
content: '';
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) scale(0);
width: 110%;
height: 110%;
background: rgba(57, 161, 255, 0.5);
transition: transform 0.5s ease;
border-radius: 50%;
}
.vote_card_hover:active:before {
transform: translate(-50%, -50%) scale(1);
}
<div class='vote_card_hover'>
<a>Test</a>
</div>