How to create accordion using checkbox and radio buttons - html

I am creating a project in which we can see the assignment and download the assignment given by college.
I used the accordion method for that....
In which 5-6 subject are there and when you click on that subject it expands and shows the assignment,from that expanded view you can download the document or view it.....
I am also adding some buttons around it like "Download" "view" "Mark as favorite" for that assignment.
I have used the checkbox for expanding the accordions, now the main problem is that When I Click anywhere on that subject 'div' it expands, but i want that it should expand only when user click on that "plus" icon ( shown at a right side )
So that all the operations like "View Document","Download Document","Mark as favorite" work on the buttons that added on the right side...
I just want that when someone click on '+' icon it should expand (Not when someone click on whole div)
Check the whole code at Codepen
#import url('https://fonts.googleapis.com/css2?family=Poppins:wght#200;300;400;500;600;700&display=swap');
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
body{
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}
::selection{
background: rgb(0,123,255,0.3);
}
.wrapper{
max-width: 600px;
padding: 0 20px;
}
.wrapper .parent-tab,
.wrapper .child-tab{
margin-bottom: 8px;
border-radius: 3px;
box-shadow: 0px 0px 15px rgba(0,0,0,0.18);
}
.wrapper .parent-tab label,
.wrapper .child-tab label{
background: #007bff;
padding: 10px 20px;
display: flex;
align-items: center;
justify-content: space-between;
cursor: pointer;
border-radius: 3px;
position: relative;
z-index: 99;
transition: all 0.3s ease;
}
.wrapper .parent-tab label:hover{
background: #006fe6;
}
.parent-tab input:checked ~ label,
.child-tab input:checked ~ label{
border-radius: 3px 3px 0 0;
background: #006fe6;
}
.wrapper label span{
color: #fff;
font-size: 18px;
font-weight: 500;
text-shadow: 0 -1px 1px #0056b3;
}
.wrapper .child-tab label span{
font-size: 17px;
}
.parent-tab label .icon{
position: relative;
height: 30px;
width: 30px;
font-size: 15px;
color: #007bff;
display: block;
background: #fff;
border-radius: 50%;
text-shadow: 0 -1px 1px #0056b3;
}
.wrapper .child-tab label .icon{
height: 27px;
width: 27px;
}
.parent-tab label .icon i{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.parent-tab input:checked ~ label .icon i:before,
.child-tab input:checked ~ label .icon i:before{
content: '\f068';
}
.wrapper .parent-tab .content,
.wrapper .child-tab .sub-content{
max-height: 0px;
overflow: hidden;
background: #fff;
border-radius: 0 0 3px 3px;
transition: all 0.4s ease;
}
.parent-tab input:checked ~ .content,
.child-tab input:checked ~ .sub-content{
max-height: 100vh;
}
.tab-3 input:checked ~ .content{
padding: 15px 20px;
}
.parent-tab .content p,
.child-tab .sub-content p{
padding: 15px 20px;
font-size: 16px;
}
.child-tab .sub-content p{
font-size: 15px;
}
input[type="radio"],
input[type="checkbox"]{
display: none;
}
.num1{
text-align: center;
margin-bottom: 20px;
}
<script src="https://kit.fontawesome.com/a076d05399.js"></script>
<div class="wrapper">
<h2 class="num1">Assignment At Glance</h2>
<!-- Accordion Heading One -->
<div class="parent-tab">
<input type="checkbox" name="tab" id="tab-1" checked>
<label for="tab-1">
<span>Engineering Physics</span>
<div class="icon"><i class="fas fa-plus"></i></div>
</label>
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing thelit. Quam, repellendus facere, id porro magnam blanditiiss quoteos dolores ratione quidem ipsam esse quos pariatur, repellat obcaecati!</p>
</div>
</div>
<!-- Accordion Heading Two -->
<div class="parent-tab">
<input type="checkbox" name="tab" id="tab-2">
<label for="tab-2">
<span>Engineering Graphics</span>
<div class="icon"><i class="fas fa-plus"></i></div>
</label>
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing thelit. Quam, repellendus facere, id porro magnam blanditiiss quoteos dolores ratione quidem ipsam esse quos pariatur, repellat obcaecati!</p>
</div>
</div>
<!-- Accordion Heading Three -->
<div class="parent-tab tab-3">
<input type="checkbox" name="tab" id="tab-3">
<label for="tab-3" class="tab-3">
<span>PPS</span>
<div class="icon"><i class="fas fa-plus"></i></div>
</label>
<div class="content">
• Assignment Completed : 3 <br>
• Assignment Remaining : 1 <br>
<br>
<!-- Sub Heading One -->
<div class="child-tab">
<input type="checkbox" name="sub-tab" id="tab-4">
<label for="tab-4">
<span>Algorithms</span>
<div class="icon"><i class="fas fa-plus"></i></div>
</label>
<div class="sub-content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing thelit dolor. Utfacilis labore, exercitationem fuga minima a illo modi vitaerse dignissimos? Vero?</p>
</div>
</div>
<!-- Sub Heading Two -->
<div class="child-tab">
<input type="checkbox" name="sub-tab" id="tab-5">
<label for="tab-5">
<span>Python</span>
<div class="icon"><i class="fas fa-plus"></i></div>
</label>
<div class="sub-content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing thelit dolor. Utfacilis labore, exercitationem fuga minima a illo modi vitaerse dignissimos? Vero?</p>
</div>
</div>
</div>
</div>
<!-- Accordion Heading Four -->
<div class="parent-tab">
<input type="checkbox" name="tab" id="tab-6">
<label for="tab-6">
<span>Accordion Heading Four</span>
<div class="icon"><i class="fas fa-plus"></i></div>
</label>
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing thelit. Quam, repellendus facere, id porro magnam blanditiiss quoteos dolores ratione quidem ipsam esse quos pariatur, repellat obcaecati!</p>
</div>
</div>
</div>

The Problem
When you are making the blue bars, they are wrapped in a label. When you click the label it is expanding the box because it checks the checkbox.
The Solution
All you need to do is to make make it so that the blue bar doesn't register clicks, but the icon does. To do this you can use the pointer-evens property. The code should look like this
.parent-tab label{
pointer-events: none;
}
.parent-tab .icon{
pointer-events: auto;
}
Disclaimer: I didn't come up with this answer, #ManirajMurugan did. (See the first comment on the question).

Related

Flip box hover with image as background

im using a flip box with a front and back content when i hover (rotateY(180deg)) . that worked for simple container (only text) but didn't work when the background was an image this is my first time using nth-child element so any advises are welcome^^.
(its a small screen version for now)
and thanks in advance.
/*
===============
SERVICES
===============
*/
.title-service {
margin-top: 100px;
text-align: center;
}
.title-service p {
margin-top: -30px;
}
.container-service {
width: 70vh;
height: 50vh;
margin-left: 30px;
background: grey;
margin-bottom: 10px;
align-items: center;
text-align: center;
padding-top: 25%;
transform-style: preserve-3d;
transition: 0.3s ease all;
}
.container-service:hover {
transform: rotateY(180deg);
}
.front-card {
backface-visibility: hidden;
position: absolute;
height: 100%;
width: 100%;
top: 0;
left: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}
.back-card {
backface-visibility: hidden;
position: absolute;
height: 100%;
width: 100%;
top: 0;
left: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
transform: rotateY(180deg);
}
.container-service h3 {
color: black;
font-size: 26px;
font-weight: 700;
}
.container-service i {
font-size: 40px;
color: black;
}
.container-service:nth-child(3) {
background-image: url(../Responsive\ Website/img-2.jpg);
background-size: cover;
position: relative;
}
.container-service:nth-child(3) .front-card::after {
content: "";
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
z-index: -1;
}
.dev h3 {
color: whitesmoke;
}
.dev i {
color: whitesmoke;
}
<!-- START SERVICES -->
<section class="service">
<div class="info-service">
<div class="title-service">
<h1>SERVICES</h1>
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit.</p>
</div>
<div class="container-service web">
<div class="front-card">
<span><i class="fas fa-palette"></i></span>
<h3>Web Design</h3>
</div>
<div class="back-card">
<p>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Libero
maxime, reiciendis, ut earum amet architecto, cum magni cumque eum
repudiandae a minus sunt! Sed porro expedita, fuga aspernatur
molestiae iste ab cupiditate repudiandae cumque officia ea.
Tenetur amet ullam voluptatum?
</p>
</div>
</div>
<div class="container-service f-e">
<div class="dev">
<div class="front-card">
<span><i class="fas fa-laptop-code"></i></span>
<h3>Front Dev</h3>
</div>
<div class="back-card">
<h3>Front Dev</h3>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Fugit
optio, eum esse doloremque molestias aspernatur.
</p>
</div>
</div>
</div>
<div class="container-service branding">
<div class="front-card">
<span><i class="fas fa-building"></i></span>
<h3>Branding</h3>
</div>
<div class="back-card">
<h3>Branding</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Consequuntur, error.
</p>
</div>
</div>
</div>
</section>
<!-- END SERVICES -->
The front and back are stacked above the parent wrapper and have inherited the parent background color, try applying the image to the front card of the third child.

Div goes to the next line in CSS [duplicate]

This question already has answers here:
Two divs side by side - Fluid display [duplicate]
(9 answers)
Closed 1 year ago.
Div with class name main goes to the next line. I don't need it. It's wrong. I've vertical navbar with display block. I don't know why it goes to the next line.
Here's HTML code:
/* Nav */
nav {
padding-left: 30px;
padding-top: 30px;
height: 100vw;
width: 290px;
border-right: 1px solid #333333;
}
.nav__link {
color: #FFFFFF;
width: 250px;
display: block;
border-radius: 8px;
padding: 6px 0px 6px 30px;
transition: background-color .2s linear;
font-family: 'Lato', sans-serif;
font-weight: 700;
font-size: 18px;
margin-top: 20px;
}
.nav__link:hover {
background-color: #707070;
}
/* Main */
.main {
margin-left: 300px;
}
<!-- Nav -->
<nav>
Project 1
Project 2
Project 3
Project 4
</nav>
<!-- Main -->
<div class="main">
<div class="project">
<h1 class="project__name">Project 1</h1>
<p class="project__description">Lorem ipsum, dolor sit amet consectetur adipisicing, elit. Facere voluptates sapiente soluta velit aliquid unde similique quas fugit animi, fugiat, non? At provident totam esse, molestias? Quos, quam. Adipisci, animi.</p>
</div>
</div>
Any ideas to solve this problem, guys?
Add display: flex; to their parent, which is currently <body>:
body {
display: flex;
}
block elements take up entire width, so nav will push the <div> to next line by default.
Side note: I recommend using more semantic elements like <aside> and <main>
/* Nav */
body {
display: flex;
}
nav {
padding-left: 30px;
padding-top: 30px;
height: 100vw;
width: 290px;
border-right: 1px solid #333333;
background: grey;
}
.nav__link {
color: #FFFFFF;
width: 250px;
display: block;
border-radius: 8px;
padding: 6px 0px 6px 30px;
transition: background-color .2s linear;
font-family: 'Lato', sans-serif;
font-weight: 700;
font-size: 18px;
margin-top: 20px;
}
.nav__link:hover {
background-color: #707070;
}
/* Main */
main {
margin-left: 300px;
}
<aside>
<nav>
Project 1
Project 2
Project 3
Project 4
</nav>
</aside>
<!-- Main -->
<main>
<div class="project">
<h1 class="project__name">Project 1</h1>
<p class="project__description">Lorem ipsum, dolor sit amet consectetur adipisicing, elit. Facere voluptates sapiente soluta velit aliquid unde similique quas fugit animi, fugiat, non? At provident totam esse, molestias? Quos, quam. Adipisci, animi.</p>
</div>
</main>

Images with text not getting aligned side by side

I want these these 3 sections to be side by side
I want these three sections of the class box to be in line side by side. I don't know what is wrong with my code. I've cross checked it many time with the code from the instructor.
Thanks for your help.
ul {
margin: 0;
padding: 0;
}
/* Global */
.container {
width: 80%;
margin: auto;
overflow: hidden;
}
/* BOXES */
#boxes {
margin-top: 20px;
}
#boxes .box {
float: left;
width: 25%;
padding: 10px;
text-align: center;
}
#boxes .box img {
width: 90px;
}
<section id="boxes">
<div class="container">
<div class="box">
<img src="./images/html5.png" alt="html5">
<h3>HTML 5 Markup</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste corrupti incidunt cumque, delectus ullam</p>
</div>
</div>
<div class="container">
<div class="box">
<img src="./images/css3.png" alt="css3">
<h3>CSS 3 Styling</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste corrupti incidunt cumque, delectus ullam</p>
</div>
</div>
<div class="container">
<div class="box">
<img src="./images/brush.png" alt="brush">
<h3>Graphic Design</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste corrupti incidunt cumque, delectus ullam</p>
</div>
</div>
</section>
You can use display: flex in the #boxes selector in your CSS file.
If you want them to be side by side you can just use flex
#boxes {
margin-top: 20px;
display: flex;
justify-content: center;
}
You can try this:
ul {
margin: 0;
padding: 0;
}
/* Global */
.container {
width: 80%;
margin: auto;
overflow: hidden;
}
/* BOXES */
#boxes {
display: flex;
margin-top: 20px;
}
#boxes .box {
float: left;
width: 25%;
padding: 10px;
text-align: center;
}
#boxes .box img {
width: 90px;
}
<section id="boxes">
<div class="container">
<div class="box">
<img src="./images/html5.png" alt="html5">
<h3>HTML 5 Markup</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste corrupti incidunt cumque, delectus ullam</p>
</div>
</div>
<div class="container">
<div class="box">
<img src="./images/css3.png" alt="css3">
<h3>CSS 3 Styling</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste corrupti incidunt cumque, delectus ullam</p>
</div>
</div>
<div class="container">
<div class="box">
<img src="./images/brush.png" alt="brush">
<h3>Graphic Design</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste corrupti incidunt cumque, delectus ullam</p>
</div>
</div>
</section>
You can use display:flex to the #boxes. It will make its child to be in one row.
Learn more about flex https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox;
body {
/* font-family: Arial, Halvetica, sans-serif;
font-size: 15px;
line-height: 1.5em; */
font: 15px/1.5 Arial, Halvetica, sans-serif;
padding: 0;
background-color: #f4f4f4;
}
ul {
margin: 0;
padding: 0;
}
a:hover {
color: #cccccc;
}
/* Global */
.container {
width: 80%;
margin: auto;
overflow: hidden;
}
.button_1 {
height: 38px;
background: #e8491d;
border: none;
padding: 0px 20px 0px 20px;
font-style: oblique;
font-weight: bold;
color: white;
}
/*header*/
header {
background: #35424a;
color: #ffffff;
padding-top: 30px;
min-height: 70px;
border-bottom: #e8491d 3px solid;
}
header a {
color: white;
text-decoration: none;
text-transform: uppercase;
font-size: 16px;
}
header li {
float: left;
display: inline;
padding: 0 20px 0 20px;
}
header #branding {
float: left;
}
header #branding h1 {
margin: 0;
}
header nav {
float: right;
margin-top: 10px;
}
header .highlight, header .current a {
color: #e8491d;
font-weight: bold;
}
/* showcase */
#showcase {
min-height: 400px;
background: url("../images/showcase.jpg") no-repeat 0-400px;
text-align: center;
color: white;
}
#showcase h1 {
margin-top: 100px;
font-size: 55px;
margin-bottom: 10px;
}
#showcase p {
font-size: 20px;
}
/*NewsLetter */
#newsletter {
padding: 15px;
color: white;
background: #35424a;
}
#newsletter h1 {
float: left;
}
#newsletter form {
margin-top: 22px;
float: right;
}
#newsletter input[type="email"] {
padding: 4px;
height: 25px;
width: 250px;
}
/* BOXES */
#boxes {
margin-top: 20px;
display:flex;
}
#boxes .box {
width: 25%;
padding: 10px;
text-align: center;
}
#boxes .box img {
width: 90px;
}
<body>
<header>
<div class="container">
<div id="branding">
<h1><span class="highlight">Sumanyu</span> Web design</h1>
</div>
<nav>
<ul>
<li class="current">Home</li>
<li class="current">About</li>
<li class="current">Services</li>
</ul>
</nav>
</div>
</header>
<section id="showcase">
<div class= "container">
<h1>Affordable professional Web Design</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste corrupti incidunt cumque, delectus ullam aut reprehenderit debitis doloremque, necessitatibus, nulla, ab fuga reiciendis rerum culpa possimus illum labore sit laudantium.</p>
</div>
</section>
<section id="newsletter">
<div class="container">
<h1>Subscribe to Our Newsletter</h1>
<form class="process.php" action="index.html" method="post">
<input type="email" placeholder="Enter your Email">
<button type="submit" class="button_1">Subscribe</button>
</form>
</div>
</section>
<section id="boxes">
<div class="container">
<div class="box">
<img src="./images/html5.png" alt="html5">
<h3>HTML 5 Markup</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste corrupti incidunt cumque, delectus ullam</p>
</div>
</div>
<div class="container">
<div class="box">
<img src="./images/css3.png" alt="css3">
<h3>CSS 3 Styling</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste corrupti incidunt cumque, delectus ullam</p>
</div>
</div>
<div class="container">
<div class="box">
<img src="./images/brush.png" alt="brush">
<h3>Graphic Design</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste corrupti incidunt cumque, delectus ullam</p>
</div>
</div>
</section>
<footer>
<p>Sumanyu Sood Web Design, Copyright © 2020 </p>
</footer>
</body>
</html>

Responsive popup window CSS

a pop-up window is displayed when the user click to a specific link. . I can not figure out how to make it responsive. On smaller screens, the bottom of the pop-up window is out of range .
HTML code:
<div class="popup-wrapper">
<div class="popup">
<div class="popup-close">x</div>
<div class="popup-content">
<h2>Job Details</h2>
<div class="popup-job-description">
<div class="job-descriptions">
<p><span class="popup-job-description-title">Title: </span>Process Engineer</p>
</div>
<div class="job-descriptions">
<p><span class="popup-job-description-company">Company: </span>Undisclosed</p>
</div>
<div class="job-descriptions">
<p><span class="popup-job-description-location">Location: </span>Naypyitaw</p>
</div>
<div class="job-descriptions">
<p><span class="popup-job-description-location">Salary: </span>$75,000</p>
</div>
<div class="job-descriptions">
<p><span class="popup-job-description-description">Description: </span>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Culpa et similique ex, iusto sint in ratione aut magnam! Accusamus eveniet aspernatur nihil? Distinctio vel fugiat eius eaque? Quas earum adipisci quis voluptate animi id atque alias. Sapiente aut explicabo voluptate!</p>
</div>
<div class="job-descriptions requirements">
<p><span class="popup-job-description-requirements">Requirements: </span><ul>
<li>Bachelor's degree</li>
<li>At least 3 years of experience in a similar position</li>
<li>Fluent in English and Mandarin</li>
</ul></p>
</div>
<a class="apply-button" href="#">Apply Now</a>
</div>
</div>
CSS here:
/Job Popup/
.model{
width:100%;
height:100%;
background-color: black;
opacity: 0.5;
position: absolute;
top:0;
}
.popup-wrapper{
opacity: 1;
background: rgba(0,0,0,0.5);
position: fixed;
top:0;
left:0;
width:100%;
height:100%;
display: none;
}
.popup-wrapper .popup{
max-width: 60%;
min-width: 40%;
background: white;
margin: auto auto;
padding: 4rem 2rem 4rem 2rem;
}
.popup-wrapper .popup h2{
text-align: center;
color:#0b1f49;
letter-spacing: 2px;
margin-bottom: 1rem;
}
.popup-wrapper .popup-close{
position:absolute;
top:8%;
right:22%;
cursor:pointer;
font-size: 22px;
}
.popup-wrapper .popup a{
background:#5286ec;
color:white;
text-decoration:none;
padding:20px 35px;
position:relative;
}
.popup-job-description{
align-content:
}
.job-descriptions {
padding:0.75rem;
}
.job-descriptions span{
color:#2260dd;
font-weight: bold;
letter-spacing: 1.5px;
}
.popup-job-description .requirements ul{
margin: 0rem 0rem 2.5rem 1rem;
}
.popup-job-description .requirements li{
font-size: 18px;
margin: 5px;
}
I also have a little problem as you may have notice with the "x" or close-window at the top right of the pop-up window, I used a the absolute value as a display but it seems that it does really work.
Just add overflow-y: scroll; to your .popup-content.
Regarding the close button, you may want to use values in em. Here percentage is percentage of the width for the y coordinate and percentage of height for y coordinate. Since height vary with content, you get unpredictable results.

Bootstrap 4 Custom Checkbox missing height

I made a checkbox with a custom checkmark with BS4. But the elements overflow the container .SamCheckbox. It seems some elements are not given full height so it breaks the document flow. Like when you forget to clear a float - but this is done with flexbox, not floats.
How can I avoid this and having the checkbox not breaking the height?
<div class="SamCheckbox custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="sam-check-1" value="18">
<i class="custom-control-indicator"></i>
</div>
I given it min-height to ensure a height but that shouldn't be necessary, I think.
.SamCheckbox {
min-height: 34px !important;
&.custom-checkbox {
.custom-control-input {
display: none;
& ~ .custom-control-indicator {
background: none;
border: 1px solid #333;
color: blue;
font-size: 1.6rem;
width: 36px;
height: 36px;
&::before {
position: absolute;
top: 5px;
left: 5px;
}
}
&:checked ~ .custom-control-indicator {
border: 1px solid #999;
background: none;
}
&:disabled ~ .custom-control-indicator {
border: none;
background: none;
}
}
}
}
How can I ensure that <div class="SamCheckbox"> contains all child elements and has full height?
Here's a codepen with usage in context:
https://codepen.io/olefrankjensen/pen/RxXEBN?editors=1100
The reason the .custom-control-indicator overflow the .SamCheckbox, is that it has position: absolute, and as that takes it out of flow, .SamCheckbox won't pick up its size.
Additionally, .SamCheckbox has padding-left: 1.5rem and .custom-control-indicator has top: 0.25rem, which further more offset the .custom-control-indicator.
Resetting those values will solve the overflow and align it properly.
.SamCheckbox {
padding-left: 0; /* added */
&.custom-checkbox {
.custom-control-input {
display: none;
& ~ .custom-control-indicator {
background: none;
border: 1px solid $color-grey-dark;
color: $color-active;
font-size: 1.6rem;
width: 36px;
height: 36px;
position: relative; /* added */
top: 0; /* added */
Updated codepen
Stack snippet
.ContractTemplateDetails {
cursor: pointer;
border: 1px solid #ccc;
padding: 2rem !important;
}
.ContractTemplateDetails:hover {
background-color: #e5e5e5;
}
.ContractTemplateDetails.checked {
padding: 2rem;
background-color: #ccc;
-webkit-box-shadow: 0.25rem 0.25rem 0 0 #999;
-moz-box-shadow: 0.25rem 0.25rem 0 0 #999;
box-shadow: 0.25rem 0.25rem 0 0 #999;
}
.ContractTemplateDetails .contract-image img {
width: 100%;
}
.ContractTemplateDetails .contract-image .image-placeholder {
max-width: 25%;
}
.ContractTemplateDetails .contract-price h2 {
font-family: Times serif;
}
.ContractTemplateDetails .contract-list, .ContractTemplateDetails .contract-list li {
margin-left: 0;
padding-left: 0;
list-style-type: none;
}
.ContractTemplateDetails .contract-list li {
text-align: left;
color: #666;
font-size: 0.8rem;
}
.ContractTemplateDetails .contract-list li:not(:first-child) {
margin-top: 1rem;
}
.SamCheckbox {
padding-left: 0;
/* added */
}
.SamCheckbox.custom-checkbox .custom-control-input {
display: none;
}
.SamCheckbox.custom-checkbox .custom-control-input ~ .custom-control-indicator {
background: none;
border: 1px solid #666;
color: blue;
font-size: 1.6rem;
width: 36px;
height: 36px;
position: relative;
/* added */
top: 0;
/* added */
}
.SamCheckbox.custom-checkbox .custom-control-input ~ .custom-control-indicator::before {
position: absolute;
top: 5px;
left: 5px;
}
.SamCheckbox.custom-checkbox .custom-control-input:checked ~ .custom-control-indicator {
border: 1px solid #666;
background: none;
}
.SamCheckbox.custom-checkbox .custom-control-input:disabled ~ .custom-control-indicator {
border: none;
background: none;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta.2/css/bootstrap.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-8">Lorem ipsum dolor sit amet consectetur adipisicing elit. Placeat distinctio cupiditate debitis similique quod eligendi animi blanditiis rem. Neque libero nam facilis blanditiis consectetur pariatur veritatis esse consequatur vel sit.</div>
<div class="col-4">Lorem ipsum dolor, sit amet consectetur adipisicing elit. Odit, nostrum at a non quidem possimus explicabo saepe eum culpa quos laboriosam repudiandae corporis velit molestiae tempora natus ea tenetur quod.</div>
</div>
<div class="row">
<div class="col-sm-5 offset-sm-1">
<section class="ContractTemplateDetails mt-sm-0 unselectable mr-sm-2 card card-block h-100 justify-content-center align-items-center" data-template-id="18">
<div class="contract-image"><img class="" src="http://freevector.co/wp-content/uploads/2010/05/29358-toy-car-outline.png" alt="Contract Basic"></div>
<h4 class="contract-title">Contract Basic</h4>
<ul class="contract-list">
<li>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Impedit non </li>
<li>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Impedit non.</li>
<li>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Impedit non </li>
<li>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Impedit non omfattet af serviceaftalen.</li>
</ul>
<div class="contract-price mt-auto">
<h2 class="component-margin-top-small">205,00 kr./md.</h2>
</div>
<div class="SamCheckbox custom-control custom-checkbox"><input type="checkbox" class="custom-control-input" id="sam-check-undefined" value="18"><i class="custom-control-indicator"></i></div>
</section>
</div>
<div class="col-sm-5">
<section class="ContractTemplateDetails mt-sm-0 unselectable mr-sm-2 checked card card-block h-100 justify-content-center align-items-center" data-template-id="18">
<div class="contract-image"><img class="" src="http://freevector.co/wp-content/uploads/2010/05/29358-toy-car-outline.png" alt="OmniCar Premium"></div>
<h4 class="contract-title mt-md">Contract Premium</h4>
<ul class="contract-list mb-md">
<li>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Impedit non .</li>
<li>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Impedit non .</li>
<li>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Impedit non mellem serviceeftersyn.</li>
<li>Reparationer som er nødvendige for, at bilen fungerer drift Lorem ipsum dolor sit amet consectetur, adipisicing elit. Impedit non skulle ske at virke. Det kan jeg næsten ikke tro! mv. Lorem ipsum dolor sit amet consectetur, adipisicing elit.
Impedit non </li>
</ul>
<div class="contract-price mt-auto">
<h2 class="component-margin-top-small">540,00 kr./md.</h2>
</div>
<div class="SamCheckbox custom-control custom-checkbox mt-sm"><input type="checkbox" class="custom-control-input" id="sam-check-5" value="19"><i class="fa fa-check custom-control-indicator"></i></div>
</section>
</div>
</div>
</div>
As a side note, one of the best ways to see what's going on in cases like this, is to e.g. add a border on the container, as done here in the original codepen. With that one most of the time will find the issue quite fast, and either immediately understand what's wrong, or, with the browser's dev.tools, check which classes/properties is applied, and their values.