I want to align the radio button and their label in center and vertical but I am only able to the centre the alignment by using text-align: centre. I have tried every method but it is not working. I am including the code for reference.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link rel="stylesheet" href="radio_button.css" />
</head>
<body>
<div style="text-align: center;">
<form id="algorithm">
<input type="radio" class="option-input radio" name="algorithm" value="fcfs" checked />
<label>FCFS</label>
<br>
<input type="radio" class="option-input radio" name="algorithm" value="sjf" />
<label>SJF</label><br>
<input type="radio" class="option-input radio" name="algorithm" value="priority" /><label>HRNN</label><br>
<input type="radio" class="option-input radio" name="algorithm" value="robin" /><label>ROUND ROBIN</label>
</form>
</div>
</body>
</html>
This above is the HTML file.
@keyframes click-wave {
0% {
height: 40px;
width: 40px;
opacity: 0.35;
position: relative;
}
100% {
height: 200px;
width: 200px;
margin-left: -80px;
margin-top: -80px;
opacity: 0;
}
}
.option-input {
-webkit-appearance: none;
-moz-appearance: none;
-ms-appearance: none;
-o-appearance: none;
appearance: none;
position: relative;
top: 13.33333px;
right: 0;
bottom: 0;
left: 0;
height: 40px;
width: 40px;
transition: all 0.15s ease-out 0s;
background: #cbd1d8;
border: none;
color: #fff;
cursor: pointer;
display: inline-block;
margin-right: 0.5rem;
outline: none;
position: relative;
z-index: 1000;
}
.option-input:hover {
background: #9faab7;
}
.option-input:checked {
background: #40e0d0;
}
.option-input:checked::before {
position: absolute;
display: inline-table;
font-size: 40.66667px;
line-height: 30px;
}
.option-input:checked::after {
-webkit-animation: click-wave 0.65s;
-moz-animation: click-wave 0.65s;
animation: click-wave 0.65s;
background: #40e0d0;
content: '';
display: block;
z-index: 100;
}
.option-input.radio {
border-radius: 50%;
}
.option-input.radio::after {
border-radius: 50%;
}
/* MY ATTEMPT
input[type="radio"] {
margin-top: -1px;
vertical-align: middle;
}
*/
This I was able to achieve till now.
This the CSS file of the input radio button.