i already have one, but was wondering if there’s an alternative way.
the point is to have a checkbox thats a circle (grey) and have a letter in the middle
.custom-size-checkbox {
text-align : center;
width : 50px;
height : 43px;
}
.custom-size-checkbox-input {
-webkit-appearance : none;
-moz-appearance : none;
appearance : none;
margin : 0;
width : 45px;
height : 45px;
display : inline-block;
position : relative;
background-color : Grey;
/* outline : 2px solid grey;*/
border-radius : 50%;
cursor : pointer;
}
.custom-size-checkbox-input:checked {
background-color: red;
}
.custom-size-checkbox-label:checked {
color : white;
}
.custom-size-checkbox-label {
display : block;
margin-top : 8px;
}
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<div class="custom-size-checkbox position-relative">
<input type="checkbox" id="customCheckbox" class="custom-size-checkbox-input" />
<label for="customCheckbox" class="custom-size-checkbox-label m-0 position-absolute top-50 start-50 translate-middle">XXL</label>
</div>
I want to point out that the above css might have some stuff that isn’t used, bc its a tweaked version of a different checkbox i used
with this i do get the end-result albeit with messing around a bit height and position relative/absolute.
but wanted to know if there’s a better way,basically i would love it if i can make it just like a simple div rounded along with d-flexing so the letter is in the middle.
also i’m having issues getting the mouse-pointer to show up when hovering as it seems certain area’s are not recognized and when checked i can only get it to turn the background red, but not the text white.
p.s. using bootstrap 5
2
Answers
I think maybe you want to do something like this. Here I have done something that when you click the text color changes. i hope helpful this code:
Try below code.Is this what you are looking for?