I have edited the default checkboxes look of HTML and created my own styles, the thing is that the property position
of the checkbox makes it bypass other elements, how can I avoid that?
Example of what is happening: https://www.screencast.com/t/ELwluGBaX
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap css -->
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.13.0/css/all.css">
<link href="https://fonts.googleapis.com/css?family=Nunito+Sans:300,400,500,700&display=swap" rel="stylesheet">
<!-- Our css -->
<title>Session Asigment</title>
<style>
label::before {
content: "";
border: solid 1px #FF6E0B;
position: absolute;
width: 1.4em;
height: 1.4em;
border-radius: 3px;
}
input[type=checkbox] {
display: none !important;
}
.checkbox-titles [type=checkbox]:checked + label:after {
/* check */
font-family: "Font Awesome 5 Free";
color: #fff;
content: "\f00c";
font-weight: 900;
padding-left: 0.2em;
padding-bottom: 0.2em;
/* Label */
position: absolute;
width: 1.4em;
height: 1.4em;
border-radius: 3px;
background-color: #FF6E0B;
}
</style>
</head>
<body>
<div class="checkbox-titles">
<input type="checkbox" value="test" id="test">
<label for="test"></label>
</body>
<!-- Bootstrap and jQuery -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<!-- JavaScript Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
<!--select2-->
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.8/css/select2.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.8/js/select2.min.js" defer></script>
</html>