CSS: Triangle indicator in color-divided div - html

I am trying to create a div that is two different colors, split horizontally, with an angled(triangle) divider/indicator that points from the left side to the right side. This is the mockup I got:
I found a guide for making something very similar here (the 'Talk Bubble' example):
https://css-tricks.com/examples/ShapesOfCSS/
and here I found an example for creating a bi-colored div:
CSS: Set a background color which is 50% of the width of the window
I have a CodePen here with what I've got, and I'm just struggling a little bit to put the pieces above together to meet the mockup. I'm trying to make sure that the angled indicator is a maximum of 100% of the height of this div, as it will be with other similar divs of other colors and I don't want overlapping edges.
https://codepen.io/chjaro/pen/MGmLxb?editors=1100
#cs-results>#csBullets {
text-align: justify;
margin: 0 auto;
width: 40em;
padding-left: 100px;
font-size: 24px;
}
#csBullets>ul>li {
list-style: none;
color: #fff;
}
#csBullets>ul>li::before {
content: "\2022";
color: #188ac5 !important;
position: relative;
top: 0em;
padding-right: 10px;
}
#csTitle {
color: white;
font-size: 48px;
margin: auto;
max-width: 75%;
padding: 20px 0 50px 0;
}
#cs-what-we-did {
height: 400px;
background: linear-gradient(90deg, #9fa0a2 40%, #58595B 40%);
z-index: -3;
margin: 0;
padding: 0 20%;
}
#csBullets {
/* background-color: #9fa0a2; */
height: 400px;
margin: -9% 0 -10% 0;
padding: 8% 0
}
#csBullets:after {
content: "";
position: absolute;
left: 66%;
top: 0;
width: 0;
height: 0;
border-top: 175px solid transparent;
border-left: 150px solid #9fa0a2;
border-bottom: 200px solid transparent;
z-index: -1
}
#media screen and (max-width: 990px) {
#csBullets:after {
display: none !important;
}
#cs-what-we-did {
height: 100%;
background: linear-gradient(90deg, #9fa0a2 50%, #58595B 50%);
z-index: -3;
}
#csBullets {
height: 100%;
}
}
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div id="cs-what-we-did" class="col-lg-12 container-fluid cs-single">
<div class="sectionTitleBar">
<h2 class="sectionTitle" style="color: #fff;">Section Title</h2>
</div>
<div class="col-md-6" style="" id="csBullets">
<h3 class="sectionTitle" style="color:#fff;">Goals</h3>
<ul>
<li>Placeholder</li>
<li>Placeholder</li>
<li>Placeholder</li>
<li>Placeholder</li>
</ul>
</div>
<div class="col-md-6" style="z-index: -1">
<h3 class="sectionTitle" style="color:#fff;">Results</h3>
<p style="text-align: left; color: #fff">Placeholder placeholder placeholder placeholder placeholder placeholder placeholder placeholder placeholder placeholder placeholder placeholder placeholder.</p>
<p style="text-align: left; color: #fff">“Placeholder placeholder placeholder placeholder placeholder ,” Placeholder says. “Placeholder placeholder placeholder placeholder placeholder placeholder placeholder placeholder placeholder placeholder placeholder placeholder placeholder placeholder
placeholder placeholder placeholder placeholder placeholder placeholder.”</p>
</div>
</div>

I would take a different approach to this and just use absolutely positioned pseudo elements to create the elements for the angle, then transform them to get the shape you want. After that you use some z-index magic to keep it behind the content in case of overlap. This way it'll always be relative to the container itself, so it'll work regardless of the container's height.
.container {
width: 100%;
display: flex;
overflow: hidden;
position: relative;
}
.title {
position: absolute;
top: 20px;
left: 0;
right: 0;
margin: 0;
text-align: center;
z-index: 3;
}
.left,
.right {
flex: 1;
padding: 50px 60px 20px;
}
.left {
z-index: 2;
background: gold;
}
.right {
background: tomato;
position: relative;
z-index: 1;
}
.right::before,
.right::after {
z-index: -1;
content: "";
background-color: gold;
position: absolute;
width: 50%;
right: 100%;
}
.right::before {
top: 0;
bottom: 48%;
transform: rotate(-15deg);
transform-origin: top right;
}
.right::after {
bottom: 0;
top: 48%;
transform: rotate(15deg);
transform-origin: bottom right;
}
<div class="container">
<h1 class="title">Lorem ipsum dolor sit amet.</h1>
<div class="left">
<h1>Lorem ipsum.</h1>
<ul>
<li>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Commodi, recusandae.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Necessitatibus assumenda sit cupiditate facere, nihil temporibus.</li>
</ul>
</div>
<div class="right">
<h1>Lorem ipsum.</h1>
<ul>
<li>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Commodi, recusandae.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Necessitatibus assumenda sit cupiditate facere, nihil temporibus.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Necessitatibus assumenda sit cupiditate facere, nihil temporibus.</li>
</ul>
</div>
</div>

Related

How to create circular background behind a div?

I am trying to recreate this card using CSS.
However I can't figure out how to create the HTML and CSS. When I create a div and give it a background cololour and relative position, the Image is getting pushed out.
.Card {
display: flex;
flex-direction: column;
align-items: center;
width: 250px;
height: 350px;
background-color: white;
}
.CardHeader {
width: 100%;
display: flex;
flex-direction: column;
}
.CardHeader div {
width: 150px;
height: 150px;
background-color: #ff9301;
display: inline;
position: relative;
left: -15px;
}
.CardHeader img {
width: 100px;
height: 100px;
background-color: red;
}
<div class="Card">
<div class="CardHeader">
<div></div>
<Image src="/imgs/desktop-solid.svg" width={100} height={100} alt="Image" />
</div>
<div class="CardBody">
<h2>Title</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Lorem ipsum dolor sit amet consectetur adipisicing elit. Lorem ipsum dolor sit amet consectetur adipisicing elit. Lorem ipsum dolor sit amet consectetur adipisicing elit.
</p>
</div>
</div>
Few things to learn:
Place the image inside the div element
Use position:absolute on the image to allow you to move the image layer
Use overflow:hidden; on the div to 'cut off' the the image so it doesn't appear outside the container.
You also don't need the extra div element inside the card header - just use the card header as the parent.
.Card {
display: flex;
flex-direction: column;
align-items: center;
width: 300px;
height: 350px;
background-color: lightgray;
border-radius:10px;
}
.CardHeader {
display: flex;
flex-direction: column;
width: 300px;
height: 150px;
background-color: #ff9301;
display: inline;
position: relative;
overflow: hidden;
border-radius: 10px 10px 0 0;
}
.CardHeader img {
width: 150px;
height: 150px;
background-color: red;
position: absolute;
top: -20%;
left: -10%;
border-radius: 50%;
}
<div class="Card">
<div class="CardHeader">
<Image src="/imgs/desktop-solid.svg" width={100} height={100} alt="Image" />
</div>
<div class="CardBody">
<h2>Title</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Lorem ipsum dolor sit amet consectetur adipisicing elit. Lorem ipsum dolor sit amet consectetur adipisicing elit. Lorem ipsum dolor sit amet consectetur adipisicing elit.
</p>
</div>
</div>

Issues with overflow auto and white-space: nowrap and flexbox

I am trying to create a scrollable horizontal timeline with a fixed width. I have overflow-x: auto on the parent container and whenever I add white-space: nowrap to that same element, the child list elements start getting cut off. I assume this is something to do with the behavior of flex-box. I have tried adding min-width: 0 to the flex elements and flex-grow: 1 but no luck.
body {
font-family: Arial, Helvetica, sans-serif;
}
.container {
height: 200px;
width: 500px;
margin: 0 auto;
overflow-x: auto;
overflow-y: hidden;
white-space: nowrap;
}
.timeline {
display: flex;
justify-content: center;
min-width: 0;
}
.timeline ol {
list-style: none;
display: flex;
justify-content: center;
}
.timeline .horizontal-line {
position: relative;
background-color: #0d6a3d;
height: 3px;
border-radius: 4px;
margin: 5em 0;
}
.event {
margin: 0px 10px;
position: relative;
}
.date {
position: relative;
text-align: center;
top: -70px;
width: 100%;
}
.date::after {
content: "";
position: absolute;
bottom: -28px;
left: 50%;
right: auto;
height: 20px;
width: 20px;
border-radius: 50%;
border: 3px solid #00a950;
background-color: #fff;
transition: 0.3s ease;
transform: translateX(-50%);
}
.content {
width: 100%;
text-align: center;
position: relative;
top: -45px;
}
<section class="container">
<div class="timeline">
<div class="horizontal-line">
<ol>
<li class="event">
<h3 class="date">07/02/2020</h3>
<p class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit</p>
</li>
<li class="event">
<h3 class="date">08/25/2020</h3>
<p class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit</p>
</li>
<li class="event">
<h3 class="date">08/25/2020</h3>
<p class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit</p>
</li>
<li class="event">
<h3 class="date">08/25/2020</h3>
<p class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit</p>
</li>
<li class="event">
<h3 class="date">08/25/2020</h3>
<p class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit</p>
</li>
<li class="event">
<h3 class="date">08/25/2020</h3>
<p class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit</p>
</li>
</ol>
</div>
</div>
</section>
Add width: fit-content; to your timeline. That gets all elements to fit in the horizontal scroll. Then you are left with the default padding-inline-start on the ol. You can remove that gap by setting padding: 0; or padding-inline-start: 0;.
body {
font-family: Arial, Helvetica, sans-serif;
}
.container {
height: 200px;
width: 500px;
margin: 0 auto;
overflow-x: auto;
overflow-y: hidden;
white-space: nowrap;
}
.timeline {
display: flex;
justify-content: center;
min-width: 0;
width: fit-content;
}
.timeline ol {
list-style: none;
display: flex;
justify-content: center;
padding: 0;
}
.timeline .horizontal-line {
position: relative;
background-color: #0d6a3d;
height: 3px;
border-radius: 4px;
margin: 5em 0;
}
.event {
margin: 0px 10px;
position: relative;
}
.date {
position: relative;
text-align: center;
top: -70px;
width: 100%;
}
.date::after {
content: "";
position: absolute;
bottom: -28px;
left: 50%;
right: auto;
height: 20px;
width: 20px;
border-radius: 50%;
border: 3px solid #00a950;
background-color: #fff;
transition: 0.3s ease;
transform: translateX(-50%);
}
.content {
width: 100%;
text-align: center;
position: relative;
top: -45px;
}
<section class="container">
<div class="timeline">
<div class="horizontal-line">
<ol>
<li class="event">
<h3 class="date">07/02/2020</h3>
<p class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit</p>
</li>
<li class="event">
<h3 class="date">08/25/2020</h3>
<p class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit</p>
</li>
<li class="event">
<h3 class="date">08/25/2020</h3>
<p class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit</p>
</li>
<li class="event">
<h3 class="date">08/25/2020</h3>
<p class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit</p>
</li>
<li class="event">
<h3 class="date">08/25/2020</h3>
<p class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit</p>
</li>
<li class="event">
<h3 class="date">08/25/2020</h3>
<p class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit</p>
</li>
</ol>
</div>
</div>
</section>

Width of a flex item doesn't change when I use %

As far as I know, width of a flex item adjusts to its content(when flex-direction: row;).
Here you see, the width of second .item is too long even though I set the width of h1 to 50%.
* {
margin: 0;
padding: 0;
}
.container {
display: flex;
justify-content: space-between;
border: 2px solid red;
padding: 10px;
}
.item {
border: 1px solid black;
}
.test {
width: 50%;
}
<div class="container">
<div class="item">Lorem ipsum dolor sit amet.</div>
<div class="item">
<h1 class="test">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Commodi,
quo.
</h1>
</div>
</div>
But when I use px instead of %, the result that I wanted comes out. (Please view it in a full page)
* {
margin: 0;
padding: 0;
}
.container {
display: flex;
justify-content: space-between;
border: 2px solid red;
padding: 10px;
}
.item {
border: 1px solid black;
}
.test {
width: 400px;
}
<div class="container">
<div class="item">Lorem ipsum dolor sit amet.</div>
<div class="item">
<h1 class="test">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Commodi,
quo.
</h1>
</div>
</div>
I can't understand how % is calculated in the first code. Can somebody help? Thanks
You have to apply the width on the .item element.
* {
margin: 0;
padding: 0;
}
.container {
display: flex;
justify-content: space-between;
border: 2px solid red;
padding: 10px;
}
.item {
border: 1px solid black;
}
.item:nth-child(2) {
width: 50%;
}
<div class="container">
<div class="item">Lorem ipsum dolor sit amet.</div>
<div class="item">
<h1 class="test">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Commodi, quo.
</h1>
</div>
</div>
You are not applying 50% to children (.item) but rather to (.test), which is not child of display:flex. Fix it and you'll get result!
* {
margin: 0;
padding: 0;
}
.container {
display: flex;
justify-content: space-between;
border: 2px solid red;
padding: 10px;
}
.item {
border: 1px solid black;
width: 50%;
}
.test {
background: yellow;
}
<div class="container">
<div class="item">Lorem ipsum dolor sit amet.</div>
<div class="item">
<h1 class="test">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Commodi,quo. </h1>
</div>
</div>

Is it possible to add an image in the top left corner of a div's border while cutting off the border?

I have this image I am trying to replicate:
Basically, I want the border to go around the image and cut off within a certain distance.
I cannot seem to get the border to cut off.
This is the HTML for this quote and image
<div class="quote-container">
<img class="testimonial-img" src="./Photos/StethoscopeVector.png" alt="">
<div class="quote-container-text">
<h3>Testimonial Quote</h3>
<p>"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean mollis<br/>erat vel ultricies imperdiet. Lorem ipsum dolor sit amet, consectetur<br/>
adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscingelit."
</p>
</div>
</div>
CSS for Quote and Image
.quote-container {
padding: 5em 0;
height: 100%
}
.testimonial-img {
position: absolute;
margin-left: 11.5em;
margin-top: -3em;
}
.quote-container-text {
text-align: center;
color: white;
margin-top: 2em;
border: 2px solid white;
width: 65%;
padding: 2em;
margin: auto;
}
Which currently looks like this image:
I have tried using shape-outside but it doesn't work and I believe it's because the image is being set to absolute.
This is the stethoscope image. White image, no background.
first of all move your image inside of your container-text and then give border to the right and bottom of it and use pseudo selectors :after and :before for the left border and top border.
for more explanation please refer this snippet.
.quote-container {
padding: 5em 0;
height: 100%;
}
.testimonial-img {
position: absolute;
top: -50px;
left: -13px;
}
.quote-container-text {
text-align: center;
color: white;
margin-top: 2em;
border-right: 2px solid white;
border-bottom: 2px solid #fff;
width: 65%;
padding: 2em;
margin: auto;
position: relative;
}
.quote-container-text:before {
content: "";
position: absolute;
bottom: 0;
left: 0;
width: 2px;
height: calc(100% - 60px);
background-color: #fff;
}
.quote-container-text:after {
position: absolute;
height: 2px;
width: calc(100% - 100px);
right: 0;
top: 0;
content: "";
background-color: #fff;
}
<body style="background-color: #2196F3">
<div class="quote-container">
<div class="quote-container-text">
<img class="testimonial-img" src="https://i.stack.imgur.com/nj8on.png" alt="">
<h3>Testimonial Quote</h3>
<p>"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean mollis<br/>erat vel ultricies imperdiet. Lorem ipsum dolor sit amet, consectetur<br/>
adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscingelit."
</p>
</div>
</div>
</body>
for background-image instead of bg-color.
.quote-container {
padding: 5em 0;
height: 100%;
background-image: url('https://media.istockphoto.com/photos/vintage-retro-grungy-background-design-and-pattern-texture-picture-id656453072?k=6&m=656453072&s=612x612&w=0&h=4TW6UwMWJrHwF4SiNBwCZfZNJ1jVvkwgz3agbGBihyE=');
background-repeat: no-repeat;
background-size: cover;
}
.testimonial-img {
position: absolute;
top: -50px;
left: -13px;
}
.quote-container-text {
text-align: center;
color: white;
margin-top: 2em;
border-right: 2px solid white;
border-bottom: 2px solid #fff;
width: 65%;
padding: 2em;
margin: auto;
position: relative;
}
.quote-container-text:before {
content: "";
position: absolute;
bottom: 0;
left: 0;
width: 2px;
height: calc(100% - 60px);
background-color: #fff;
}
.quote-container-text:after {
position: absolute;
height: 2px;
width: calc(100% - 100px);
right: 0;
top: 0;
content: "";
background-color: #fff;
}
<body>
<div class="quote-container">
<div class="quote-container-text">
<img class="testimonial-img" src="https://i.stack.imgur.com/nj8on.png" alt="">
<h3>Testimonial Quote</h3>
<p>"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean mollis<br/>erat vel ultricies imperdiet. Lorem ipsum dolor sit amet, consectetur<br/>
adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscingelit."
</p>
</div>
</div>
</body>
Thank You...
Your image has a transparent background, and it appears above the border. To fix that, you can set the border on an absolutely positioned pseudo-element (::before), and use clip-path to remove the top left corner:
.quote-container {
padding: 5em;
background: steelblue;
}
.quote-container-text {
position: relative;
width: 65%;
padding: 2em;
margin: auto;
text-align: center;
color: white;
}
.quote-container-text::before {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
border: 2px solid white;
clip-path: polygon(55px 0%, 100% 0%, 100% 100%, 0% 100%, 0% 55px, 55px 55px);
content: '';
}
.testimonial-img {
position: absolute;
top: 0;
left: 0;
transform: translate(-50%, -50%);
}
body {
margin: 0;
}
<div class="quote-container">
<div class="quote-container-text">
<img class="testimonial-img" src="https://i.stack.imgur.com/nj8on.png" alt="">
<h3>Testimonial Quote</h3>
<p>"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean mollis<br/>erat vel ultricies imperdiet. Lorem ipsum dolor sit amet, consectetur<br/> adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscingelit."
</p>
</div>
</div>
An easy way to do this would be to use an image with a background color the same as the background color of the outermost container. Also, it's important to realize that setting something to absolute will make it absolute to the innermost container that has a relative positioning. Note that I used some random image from the web for the example, but you can conform it to your image. If you want your transparent image to have a background, wrap it in a div and set the background of the div.
First move the image inside the quote container text.
<div class="quote-container">
<div class="quote-container-text">
<div id="test-img-container">
<img class="testimonial-img" src="https://cdn3.iconfinder.com/data/icons/medical-174/100/healthy-06-512.png" alt="">
</div>
<h3>Testimonial Quote</h3>
<p>"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean mollis<br/>erat vel ultricies imperdiet. Lorem ipsum dolor sit amet, consectetur<br>
adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscingelit."
</p>
</div>
</div>
Next set the image to absolute with top and left stylings and make the quote-container-text element to be relatively positioned:
.quote-container {
padding: 5em 0;
height: 100%;
background:steelblue;
}
#test-img-container{
position: absolute;
left:-25px;
top:-25px;
background:steelblue;
}
.testimonial-img {
width:50px;
height:auto;
}
.quote-container-text {
text-align: center;
color: white;
margin-top: 2em;
border: 2px solid white;
width: 65%;
padding: 2em;
position:relative;
margin: auto;
}
Also note that this works best if you specify a hard width to the image so that you can evenly use the margin stylings on the image.
https://jsfiddle.net/dgf1ms8r/7/

Bootstrap equal height columns

I'm trying to achieve equal height of two columns. The content IRL is dynamic. Layout (desktop) normal columns (33% width each), on mobile stack cols. I tried wrapping with .row and using 'd-flex' but nothing works.
Here's a codepen:
https://codepen.io/olefrankjensen/pen/RxXEBN
Please help as I don't understand Flexbox yet.
.ContractTemplateDetails {
cursor: pointer;
border: 1px solid #ccc;
padding: 2rem !important;
height: 100%;
}
.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 {
list-style: 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 {
min-height: 34px !important;
}
.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;
}
.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/twitter-bootstrap/4.0.0-beta.2/css/bootstrap.css" rel="stylesheet"/>
<div class="container">
<div class="row d-flex component-margin-top-small justify-content-center">
<section class="ContractTemplateDetails mt-sm-0 col-sm-4 d-inline-flex flex-column align-items-center justify-content-center unselectable mr-sm-2" 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 mt-md">Contract Basic</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 </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 mt-sm"><input type="checkbox" class="custom-control-input" id="sam-check-undefined" value="18"><i class="custom-control-indicator"></i></div>
</section>
<section class="ContractTemplateDetails mt-sm-0 col-sm-4 d-inline-flex flex-column align-items-center justify-content-center unselectable mt-3 checked" data-template-id="19">
<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>
Just remove height: 100%; from the left column .ContractTemplateDetails
.ContractTemplateDetails {
cursor: pointer;
border: 1px solid #ccc;
padding: 2rem !important;
}
Two initial settings on a flex container are flex-direction: row and align-items: stretch.
This means that children of a flex container will automatically share equal height.
However, this only works if the height on the children is set to auto. If you define a height on a child, that overrides align-items, disabling the equal heights feature.
So, to make your columns have equal height, remove the specified height on flex items:
.ContractTemplateDetails {
cursor: pointer;
border: 1px solid #ccc;
padding: 2rem !important;
/* height: 100%; <--- remove this */
}
revised codepen