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.
Related
I'm building a site and I've encountered a problem that an inline block doesn't work for me, I'm trying to add an inline block to the <section id="section-three"> section, but it doesn't work, I tried to add it to specific divs, but it also doesn't work, how can I fix it? I don't need to use flex, I need to use the inline block. I would like it to be like this https://prnt.sc/V14eLuOjtX2k
* {
margin: 0;
padding: 0;
}
body {
margin: 0;
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
font-size: 17px;
color: #926239;
line-height: 1.6;
}
#header {
background-image: url("http://traversymedia.com/downloads/assets/beachshowcase.jpg");
background-size: cover;
background-position: center;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
padding: 0 20px;
}
h1 {
font-size: 50px;
line-height: 1.2;
}
#text {
margin: 5px;
font-size: 20px;
}
.button {
font-size: 18px;
text-decoration: none;
color: #926239;
border: #926239 1px solid;
padding: 10px 20px;
border-radius: 10px;
margin-top: 20px;
}
.button:hover {
background-color: #926239;
color: white;
}
#section-three {
display: inline-block;
}
.block {
background: #926239;
color: white;
padding: 20px;
}
#block-two {
padding: 20px;
}
#block-three {
background: #926239;
color: #fff;
padding: 20px;
}
<header id="header">
<h1>Welcome To The Beach</h1>
<p id="text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Modi officiis ipsum officia numquam expedita ullam.
</p>
Read More
</header>
<section id="section-three">
<div class="block">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</div>
<div id="block-two">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</div>
<div class="block">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</div>
</section>
You are applying display:inline-block to the container/parent (#section-three), but you should apply it to its children instead (and add a width setting!). Replace your #section-three {...} rule with
#section-three > * {
display: inline-block;
width: 32.66%;
box-sizing: border-box;
}
BTW: Still, using display:flex would be better since finding an appropriate width setting for the inline-blocks is difficult here.
* {
margin: 0;
padding: 0;
}
body {
margin: 0;
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
font-size: 17px;
color: #926239;
line-height: 1.6;
}
#header {
background-image: url("http://traversymedia.com/downloads/assets/beachshowcase.jpg");
background-size: cover;
background-position: center;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
padding: 0 20px;
}
h1 {
font-size: 50px;
line-height: 1.2;
}
#text {
margin: 5px;
font-size: 20px;
}
.button {
font-size: 18px;
text-decoration: none;
color: #926239;
border: #926239 1px solid;
padding: 10px 20px;
border-radius: 10px;
margin-top: 20px;
}
.button:hover {
background-color: #926239;
color: white;
}
#section-three > * {
display: inline-block;
width: 32.66%;
box-sizing: border-box;
}
.block {
background: #926239;
color: white;
padding: 20px;
}
#block-two {
padding: 20px;
}
#block-three {
background: #926239;
color: #fff;
padding: 20px;
}
<header id="header">
<h1>Welcome To The Beach</h1>
<p id="text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Modi officiis ipsum officia numquam expedita ullam.
</p>
Read More
</header>
<section id="section-three">
<div class="block">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</div>
<div id="block-two">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</div>
<div class="block">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</div>
</section>
You should definitely just use flexbox. Browser support is wide. Inline block solution is also included below if you really want to use that.
* {
margin: 0;
padding: 0;
}
body {
margin: 0;
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
font-size: 17px;
color: #926239;
line-height: 1.6;
}
#header {
background-image: url("http://traversymedia.com/downloads/assets/beachshowcase.jpg");
background-size: cover;
background-position: center;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
padding: 0 20px;
}
h1 {
font-size: 50px;
line-height: 1.2;
}
#text {
margin: 5px;
font-size: 20px;
}
.button {
font-size: 18px;
text-decoration: none;
color: #926239;
border: #926239 1px solid;
padding: 10px 20px;
border-radius: 10px;
margin-top: 20px;
}
.button:hover {
background-color: #926239;
color: white;
}
#section-three {
display: flex;
}
.block {
background: #926239;
color: white;
padding: 20px;
}
#block-two {
padding: 20px;
}
#block-three {
background: #926239;
color: #fff;
padding: 20px;
}
<header id="header">
<h1>Welcome To The Beach</h1>
<p id="text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Modi officiis ipsum officia numquam expedita ullam.
</p>
Read More
</header>
<section id="section-three">
<div class="block">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</div>
<div id="block-two">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</div>
<div class="block">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</div>
</section>
If you really want to use inline block for some reason you need to remove the whitespace from your HTML, add a width to your child divs and set them to box-sizing: border-box to work more easily with the padding you have added to them.
* {
margin: 0;
padding: 0;
}
body {
margin: 0;
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
font-size: 17px;
color: #926239;
line-height: 1.6;
}
#header {
background-image: url("http://traversymedia.com/downloads/assets/beachshowcase.jpg");
background-size: cover;
background-position: center;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
padding: 0 20px;
}
h1 {
font-size: 50px;
line-height: 1.2;
}
#text {
margin: 5px;
font-size: 20px;
}
.button {
font-size: 18px;
text-decoration: none;
color: #926239;
border: #926239 1px solid;
padding: 10px 20px;
border-radius: 10px;
margin-top: 20px;
}
.button:hover {
background-color: #926239;
color: white;
}
#section-three > div{
display: inline-block;
width: 33.333%;
box-sizing: border-box;
}
.block {
background: #926239;
color: white;
padding: 20px;
}
#block-two {
padding: 20px;
}
#block-three {
background: #926239;
color: #fff;
padding: 20px;
}
<header id="header">
<h1>Welcome To The Beach</h1>
<p id="text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Modi officiis ipsum officia numquam expedita ullam.
</p>
Read More
</header>
<section id="section-three">
<div class="block">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</div><div id="block-two">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</div><div class="block">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</div>
</section>
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.
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>
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
How can I arrange horizontal columns with fixed top header on each text block?
Text blocks overlaps each other on overflow.
I want to see like on this screenshot
You can see the problem at jsFiddle
or this:
p {
margin: 0;
}
.container {
outline: 1px dotted gray;
height: 200px;
width: 400px;
white-space: nowrap;
overflow-x: auto;
}
.column {
outline: 1px dotted green;
display: inline-block;
vertical-align: top;
white-space: normal;
column-width: 100vw;
width: min-content;
min-width: 50%;
height: 100%;
}
.header {
column-span: all;
white-space: nowrap;
}
<div class="container">
<div class="column">
<h2 class="header">Lorem ipsum dolor sit..</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Pariatur, dicta aut a at sunt quasi aspernatur. Ullam porro, consequatur est quo voluptatum atque. Delectus, dicta, saepe? Delectus sapiente officiis soluta maiores voluptatum voluptates culpa. Libero consectetur aliquid temporibus, dignissimos</p>
</div>
<div class="column">
<h2 class="header">Lorem</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur, explicabo.</p>
</div>
<div class="column">
<h2 class="header">Lorem</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit</p>
</div>
<div class="column">
<h2 class="header">Lorem</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit</p>
</div>
</div>
Or what does another way exist?
https://jsfiddle.net/1x22mtkt/1/
Check this out. You can adjust the min-height according to your need. my suggestion would be to set it to what your largest column would be so that each column would be of same size.
p {
margin: 0;
}
.container {
outline: 1px dotted gray;
width: 400px;
white-space: nowrap;
overflow-x: auto;
}
.column {
outline: 1px dotted gray;
min-height:230px;
display: inline-block;
vertical-align: top;
white-space: normal;
column-width: 100vw;
width: min-content;
min-width: 60%;
height: 100%;
}
.column p{
word-break: break-all;
}
.header {
column-span: all;
white-space: nowrap;
}