I have some inputs of type radio
. I have change the colour of inner and outer colour using the property of accent-color
. Now the problem is open hovering over it makes it more darker and when it is clicked (keeping mouse button clicked and not removing the finger from clicked), it makes it more lighter.
You can also seen in the snippet. I tried putting background-color: transparent
but nothing works.
Expected Result: I just want to keep the red color as it is, not making it more darker on hover or lighter upon pressed click. Color red is for example and actually I am using other colors too.
input[type="radio"]:checked {
accent-color: red;
}
input[type="radio"]:hover {
accent-color: red;
}
.radio {
width: 60px;
height: 60px;
}
<input type="radio" class="radio">
2
Answers
You do not need any JavaScript to do this, nor to customize radio buttons at all.
You can use the CSS
appearance
property as well as some browser-fixed versions of it like-webkit-appearance
for responsiveness.Here is an example of a radio button that I set
appearance
tonone
which removes the border you see around the radio button. Then, I made a fake border which represents the old one so this border stays the same even when hovering it:Note that this code was just made to mimic the old radio button, but you can change all of the CSS to fit your specific needs.
One way, without JS, is to keep the radio button(s) but encase them in divs which have an after pseudo element on top which has the wanted styling when the input is checked.