I have a design for a radio input that has a circle in the middle with the pseudo element ::before
But when I make the input size an odd number, it is not completely centered
It appears more in smaller sizes
.input-radio {
display: flex;
gap: 10px;
height: fit-content;
}
.input-radio-button {
--Primary-color:#07f;
display: block;
--size:15px;
width: var(--size,10px);
height: var(--size,10px);
font-size: 13px;
aspect-ratio: 1;
border: var(--border-length,calc(var(--size,10px) / 7)) var(--Primary-color,#07f) solid;
border-radius: 50%;
cursor: pointer;
position: relative;
background: none;
flex-grow: 0;
flex-shrink: 0;
}
.input-radio-button::before {
content: "";
width: 100%;
aspect-ratio: 1;
border-radius: 50%;
background: var(--Primary-color);
display: block;
position: absolute;
left: 50%;
top: 50%;
font-family: Fontawesome;
font-size: 1.2em;
color: var(--Primary-color);
translate: -50% -50%;
transition: scale .2s .1s;
}
<div class="input input-radio checked">
<button class="input-radio-button"></button> <!-- the radio button -->
<label class="input-radio-label">banana</label>
</div>
2
Answers
I briefly put a parent element and centered it vertically. it is the simplest solution.
I have applied and demonstrated below.
centered without altering the HTML, just add
align-items: center;
to.input-radio