aligning multiple div headings in same height - html

I'm writing an HTML page that has 3 divs in it. and each div has a heading and a para. currently, the para is getting aligned as per the heading content height. How can I make sure that the paras in all the divs start at the same position irrespective of the h2 content?
Here is my current code.
.parent{
display: flex;
}
.child{
border: 1px solid black;
margin: 1em;
padding: 1em;
}
.child h2{
border-bottom: 1px solid;
min-height: max-content;
}
<div class="parent">
<div class="child">
<h2>Proper heading with more co</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam,</p>
</div>
<div class="child">
<h2>large heading that is bigger than proper heading</h2>
<p>labore odio minima cumque molestiae amet vitae! Voluptatum</p>
</div>
<div class="child">
<h2>small</h2>
<p>
cupiditate unde vel culpa veritatis eius dicta, quia, quas dolores
similique hic! Iure.
</p>
</div>
</div>

if you set the height of h2 to a specific value, it will be right!
for example:
.parent{
display: flex;
}
.child{
border: 1px solid black;
margin: 1em;
padding: 1em;
}
.child h2{
border-bottom: 1px solid;
height: 60px;
}
<div class="parent">
<div class="child">
<h2>Proper heading with more co</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam,</p>
</div>
<div class="child">
<h2>large heading that is bigger than proper heading</h2>
<p>labore odio minima cumque molestiae amet vitae! Voluptatum</p>
</div>
<div class="child">
<h2>small</h2>
<p>
cupiditate unde vel culpa veritatis eius dicta, quia, quas dolores
similique hic! Iure.
</p>
</div>
</div>

Related

Make a flex item grow at hover without affecting the other flex elements, while keep box heights equivalent when not hovered

I have box elements in a flex container. I want the paragraph in a box to display when hovering over the box. However, the hovered box makes the other boxes grow too. Is there a way to avoid affecting the other boxes when hovering one box?
I would try: align-items:flex-start, but I want the boxes to be equivalent in height when they are not hovered.
So align-items:flex-start does not keep the boxes' height equivalent when they are not hovered.
I want the box to enlarge when hovered without affecting the other boxes and turn back to the equivalent height when not hovered.
Codepen link: https://codepen.io/lemour-sudo/pen/yLMQOpE
.container > * {
width: 25em;
padding: 1em;
text-align: center;
}
.container {
display: flex;
justify-content: space-around;
margin: 3em 10em;
border: solid 3px green;
}
p {
display: none;
}
.box {
border: solid 3px red;
}
.box:hover p {
display: block;
}
<div class="container">
<div class="box">
<h1>Box 1</h1>
<p>
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nam tenetur amet dignissimos, accusantium molestias tempora!
</p>
</div>
<div class="box">
<h1>Box 2</h1>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Iusto voluptatum labore totam natus illo, magni inventore cupiditate hic omnis ipsam vero nobis enim dicta perferendis facilis tenetur quaerat! Voluptas, voluptatum.
</p>
</div>
</div>
I'm not sure exactly how to do what you want but I think this way is better. It's more customizable. I agree with vals answer but If you don't want to make the container to grow all the way down this way is better.
* {
margin: 0;
padding: 0;
box-sizing:border-box;
}
.con {
width: 90%;
display: flex;
align-items: center;
justify-content: space-around;
border: 3px solid black;
}
.item {
border: 3px solid red;
width: 200px;
height: 200px;
display: flex;
align-items: center;
justify-content: center;
position: relative;
background-color: cadetblue;
}
.text-con {
position: absolute;
width: 100%;
top: 100%;
display: none;
background-color: cadetblue;
}
.item:hover .text-con {
display: block;
}
<!DOCTYPE html>
<html>
<head>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<link rel='stylesheet' type='text/css' media='screen' href='style.css'>
</head>
<body>
<div class="con">
<div class="item">
<h1>box1</h1>
<div class="text-con">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Facilis minus consequatur similique quas excepturi dignissimos optio nulla possimus</p>
</div>
</div>
<div class="item">
<h1>box2</h1>
<div class="text-con">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Facilis minus consequatur similique quas excepturi dignissimos optio nulla possimus</p>
</div>
</div>
<div class="item">
<h1>box3</h1>
<div class="text-con">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Facilis minus consequatur similique quas excepturi dignissimos optio nulla possimus</p>
</div>
</div>
</div>
</body>
</html>
May be setting flex-start on hover of the container?
.container > * {
width: 25em;
padding: 1em;
text-align: center;
}
.container {
display: flex;
justify-content: space-around;
margin: 3em 10em;
border: solid 3px green;
}
.container:hover {
align-items: flex-start;
}
p {
display: none;
}
.box {
border: solid 3px red;
}
.box:hover p {
display: block;
}
<div class="container">
<div class="box">
<h1>Box 1</h1>
<p>
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nam tenetur amet dignissimos, accusantium molestias tempora!
</p>
</div>
<div class="box">
<h1>Box 2 bigger than 1</h1>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Iusto voluptatum labore totam natus illo, magni inventore cupiditate hic omnis ipsam vero nobis enim dicta perferendis facilis tenetur quaerat! Voluptas, voluptatum.
</p>
</div>
</div>
Another solution, with different heights in the initial state
.container > * {
width: 25em;
padding: 1em;
text-align: center;
}
.container {
display: flex;
justify-content: space-around;
margin: 3em 10em;
border: solid 3px green;
}
.container:hover {
align-items: flex-start;
}
p {
display: none;
}
.box {
border: solid 3px red;
height: fit-content;
}
.box:hover p {
display: block;
}
<div class="container">
<div class="box">
<h1>Box 1</h1>
<p>
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nam tenetur amet dignissimos, accusantium molestias tempora!
</p>
</div>
<div class="box">
<h1>Box 2 bigger than 1</h1>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Iusto voluptatum labore totam natus illo, magni inventore cupiditate hic omnis ipsam vero nobis enim dicta perferendis facilis tenetur quaerat! Voluptas, voluptatum.
</p>
</div>
</div>

How to push the footer to the bottom of the page [duplicate]

This question already has answers here:
What is a clearfix?
(10 answers)
How do you get the footer to stay at the bottom of a Web page?
(32 answers)
Fill remaining vertical space with CSS using display:flex
(6 answers)
Closed 2 years ago.
I have seen many answers but none seem to work for me...
My footer has come right next to the paragraphs. How can I get them to down of the page... Also how to make the whole page be seen at the same time without needing to scroll down?
Below is my code:
body {
margin: 0;
padding: 0;
background: #85dcb8;
}
header {
background: coral;
padding: 1px;
margin: 0px;
text-align: center;
border-bottom: black 4px solid;
float: center;
}
header h1 {
margin: 0px;
}
header p {
border-bottom: solid 5px black;
display: inline-block;
padding-bottom: 10px;
}
.container {
display: grid;
grid-template-columns: repeat(3, 1fr);
text-align: center;
width: 70%;
margin-left: 20%;
}
.side-bar {
grid-gap: 2px;
padding-left: 10px;
float: left;
}
.links {
display: block;
width: 100%;
padding: 10px 20px;
border-bottom: 1px solid black;
}
a {
text-decoration: none;
color: red;
}
a:hover {
color: blue;
text-decoration: underline;
}
footer {
background-color: #000000;
color: #fff;
line-height: normal;
word-spacing: 2px;
text-align: center;
padding: 50px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<title>Web Page</title>
</head>
<body>
<header>
<h1>Welcome to my web page</h1>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Deleniti, ab!
</p>
</header>
<aside>
<div class="side-bar">
<div class="links">Page 1</div>
<div class="links">Page 2</div>
<div class="links">Page 3</div>
<div class="links">Page 4 </div>
<div class="links">Page 5</div>
<div class="links">Page 6</div>
<div class="links">Page 7</div>
<div class="links">Page 8</div>
<div class="links">Page 9</div>
<div class="links">Page 10</div>
</div>
</aside>
<section>
<div class="container">
<div>
<h2>Heading 1</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 2</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 3</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 4</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 5</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 6</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
</div>
</section>
<footer>
This webpage officialy belongs to Anirudh. Copyrights since 2020 ©
</footer>
</body>
</html>
Adding a margin and giving it a particular value makes it hard in math...So I would prefer some easier method with simple CSS.
Image of how it looks for me.
Also any mistakes in my code that can be improved to make it more efficient?
Thanks.
EDIT: Adding an empty div helped me...Empty div with the class of clr and using clear:both; for the clr class in CSS works..
body {
margin: 0;
padding: 0;
background: #85dcb8;
}
header {
background: coral;
padding: 1px;
margin: 0px;
text-align: center;
border-bottom: black 4px solid;
float: center;
}
header h1 {
margin: 0px;
}
header p {
border-bottom: solid 5px black;
display: inline-block;
padding-bottom: 10px;
}
.container {
display: grid;
grid-template-columns: repeat(3, 1fr);
text-align: center;
width: 70%;
margin-left: 20%;
}
.side-bar {
grid-gap: 2px;
padding-left: 10px;
float: left;
}
.links {
display: block;
width: 100%;
padding: 10px 20px;
border-bottom: 1px solid black;
}
a {
text-decoration: none;
color: red;
}
a:hover {
color: blue;
text-decoration: underline;
}
footer {
background-color: #000000;
color: #fff;
line-height: normal;
word-spacing: 2px;
text-align: center;
padding: 50px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<title>Web Page</title>
</head>
<body>
<header>
<h1>Welcome to my web page</h1>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Deleniti, ab!
</p>
</header>
<aside>
<div class="side-bar">
<div class="links">Page 1</div>
<div class="links">Page 2</div>
<div class="links">Page 3</div>
<div class="links">Page 4 </div>
<div class="links">Page 5</div>
<div class="links">Page 6</div>
<div class="links">Page 7</div>
<div class="links">Page 8</div>
<div class="links">Page 9</div>
<div class="links">Page 10</div>
</div>
</aside>
<section>
<div class="container">
<div>
<h2>Heading 1</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 2</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 3</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 4</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 5</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 6</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 4</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 5</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 6</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
</div>
</section>
<footer>
This webpage officialy belongs to Anirudh. Copyrights since 2020 ©
</footer>
</body>
</html>
It's working...
body {
margin: 0;
padding: 0;
background: #85dcb8;
}
header {
background: coral;
padding: 1px;
margin: 0px;
text-align: center;
border-bottom: black 4px solid;
float: center;
}
header h1 {
margin: 0px;
}
header p {
border-bottom: solid 5px black;
display: inline-block;
padding-bottom: 10px;
}
.container {
display: grid;
grid-template-columns: repeat(3, 1fr);
text-align: center;
width: 70%;
margin-left: 20%;
}
.side-bar {
grid-gap: 2px;
padding-left: 10px;
float: left;
}
.links {
display: block;
width: 100%;
padding: 10px 20px;
border-bottom: 1px solid black;
}
a {
text-decoration: none;
color: red;
}
a:hover {
color: blue;
text-decoration: underline;
}
footer {
background-color: #000000;
color: #fff;
line-height: normal;
word-spacing: 2px;
text-align: center;
padding: 50px;
clear: both;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<title>Web Page</title>
</head>
<body>
<header>
<h1>Welcome to my web page</h1>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Deleniti, ab!
</p>
</header>
<aside>
<div class="side-bar">
<div class="links">Page 1</div>
<div class="links">Page 2</div>
<div class="links">Page 3</div>
<div class="links">Page 4 </div>
<div class="links">Page 5</div>
<div class="links">Page 6</div>
<div class="links">Page 7</div>
<div class="links">Page 8</div>
<div class="links">Page 9</div>
<div class="links">Page 10</div>
<div class="links">Page 7</div>
<div class="links">Page 8</div>
<div class="links">Page 9</div>
<div class="links">Page 10</div>
</div>
</aside>
<section>
<div class="container">
<div>
<h2>Heading 1</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 2</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 3</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 4</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 5</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 6</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 4</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 5</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 6</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
</div>
</section>
<footer>
This webpage officialy belongs to Anirudh. Copyrights since 2020 ©
</footer>
</body>
</html>
You can check now... it's working
section, aside {
min-height: calc(100vh - 100px);
/* here, replace 100px with the size of your header and footer */
}
This makes it so the main content is, at a minimum, the size of the screen minus the header and the footer size, thus pushing the footer to the bottom of the page.
As for the rest of your code, it looks fine to me.
body {
margin: 0;
padding: 0;
background: #85dcb8;
}
header {
background: coral;
padding: 1px;
margin: 0px;
text-align: center;
border-bottom: black 4px solid;
float: center;
}
header h1 {
margin: 0px;
}
header p {
border-bottom: solid 5px black;
display: inline-block;
padding-bottom: 10px;
}
.container {
display: grid;
grid-template-columns: repeat(3, 1fr);
text-align: center;
width: 70%;
margin-left: 20%;
}
.side-bar {
grid-gap: 2px;
padding-left: 10px;
float: left;
}
.links {
display: block;
width: 100%;
padding: 10px 20px;
border-bottom: 1px solid black;
}
a {
text-decoration: none;
color: red;
}
a:hover {
color: blue;
text-decoration: underline;
}
footer {
background-color: #000000;
color: #fff;
line-height: normal;
word-spacing: 2px;
text-align: center;
padding: 50px;
clear: both;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<title>Web Page</title>
</head>
<body>
<header>
<h1>Welcome to my web page</h1>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Deleniti, ab!
</p>
</header>
<aside>
<div class="side-bar">
<div class="links">Page 1</div>
<div class="links">Page 2</div>
<div class="links">Page 3</div>
<div class="links">Page 4 </div>
<div class="links">Page 5</div>
<div class="links">Page 6</div>
<div class="links">Page 7</div>
<div class="links">Page 8</div>
<div class="links">Page 9</div>
<div class="links">Page 10</div>
<div class="links">Page 7</div>
<div class="links">Page 8</div>
<div class="links">Page 9</div>
<div class="links">Page 10</div>
</div>
</aside>
<section>
<div class="container">
<div>
<h2>Heading 1</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 2</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 3</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 4</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 5</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
<div>
<h2>Heading 6</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum facilis possimus consequuntur optio libero. Beatae praesentium officia quos odio saepe.
</p>
</div>
</div>
</section>
<footer>
This webpage officialy belongs to Anirudh. Copyrights since 2020 ©
</footer>
</body>
</html>

Aligning elements in row to top?

I'm trying to align the contents of a row, which is inside of a container, to the top of said row.
This is my current html:
<div class="container">
<div class="row">
<div class="ticket">
<!-- content -->
</div>
</div>
</div>
CSS for ticket:
<style>
.ticket{
border:5px solid black;
border-radius: 15px 50px 30px 5px;
width:20%;
height: fit-content;
display:inline-block;
clear: left;
margin-left:30px;
background-color:#eee;
}
</style>
"row" and "container" are both bootstrap.
Trying to align the 'tickets' with the top (red line)
I've tried using align-content and align-items but neither seem to be doing anything. Any help would be appreciated! Thank you.
You can use align-items: flex-start; in container of tickets.
.ticket {
display:flex;
align-items:flex-start;
}
.tick {
padding:20px;
border:4px solid #000;
margin:50px;
border-radius:0 30px 0 0;
}
<div class="container">
<div class="row">
<div class="ticket">
<div class="tick">Lorem ipsum dolor sit amet consectetur, adipisicing elit. Quisquam adipisci suscipit, labore accusamus, libero ad dolorum officia error quo, et molestiae fugit placeat maxime ratione vel minus delectus magni. Consequatur! Lorem ipsum dolor sit amet consectetur, adipisicing elit. Quisquam adipisci suscipit, labore accusamus, libero ad dolorum officia error quo, et molestiae fugit placeat maxime ratione vel minus delectus magni. Consequatur!Lorem ipsum dolor sit amet consectetur, adipisicing elit. Quisquam adipisci suscipit, labore accusamus, libero ad dolorum officia error quo, et molestiae fugit placeat maxime ratione vel minus delectus magni. Consequatur!</div>
<div class="tick">Lorem ipsum dolor sit amet consectetur, adipisicing elit. Quisquam adipisci suscipit, labore accusamus</div>
<div class="tick">Lorem ipsum dolor sit amet consectetur, adipisicing elit. </div>
</div>
</div>
</div>
Try to use next css code:
.ticket {
display: flex;
}
.item-in-container {
#flex: 1;
}
Uncomment flex: 1; if you want them to have the same width
If you used the default behaviour of bootstrap it's aligned to the top:
.ticket {
height: 100px;
background-color: red;
}
.ticket:nth-child(2) {
height: 70px;
}
.ticket:nth-child(3) {
height: 50px;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="ticket col-3 m-3"></div>
<div class="ticket col-3 m-3"></div>
<div class="ticket col-3 m-3"></div>
</div>
</div>

Div height follow smaller div height

I have two divs, one beside the other. The left one will have a lot of content, so i want to put scrollbar on it. The right div will have less content so left div should follow height of right div.
Content of right div is dynamic so I can't set max-height of left div. I tried with display:table-cell but unsuccessfully.
.container {
display: table;
border: 2px solid red;
}
.row {
display: table-row;
}
.cell {
display: table-cell;
width: 30px;
border: 2px solid blue;
}
<div class="container">
<div class="row">
<div class="cell">CELL1: Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellendus a facilis saepe. Commodi exercitationem, provident nemo ea distinctio dolor ullam ab facere blanditiis inventore debitis nobis vitae maxime suscipit accusantium.</div>
<div class="cell">CELL2: lorem lorem lorem lorem</div>
</div>
</div>
JSFIDDLE DEMO
You can do this by wrapping the first cell (I call it with first class here) and calling it absolute.
<div class="cell first">
<div>
CELL1: Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellendus a facilis saepe. Commodi exercitationem, provident nemo ea distinctio dolor ullam ab facere blanditiis inventore debitis nobis vitae maxime suscipit accusantium.
</div>
</div>
and apply this:
.cell.first div{
position: absolute;
top: 0;
left: 0;
width: 100%;
}
and overflow-y: auto for each cell.
Maybe you have to adjust the widths. See example below:
.container {
display: table;
border: 2px solid red;
}
.row {
display: table-row;
}
.cell {
display: table-cell;
width: 30px;
border: 2px solid blue;
position: relative;
overflow-y: auto;
}
.cell.first div{
position: absolute;
top: 0;
left: 0;
width: 100%;
}
<div class="container">
<div class="row">
<div class="cell first">
<div>
CELL1: Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellendus a facilis saepe. Commodi exercitationem, provident nemo ea distinctio dolor ullam ab facere blanditiis inventore debitis nobis vitae maxime suscipit accusantium.
</div>
</div>
<div class="cell">CELL2: lorem lorem lorem lorem</div>
</div>
</div>
Cheers! Let me know your feedback on this. Thanks!
try this,
HTML
<div class="container">
<div class="row">
<div class="cell">
<div class="cell-content">
CELL1: Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellendus a facilis saepe. Commodi exercitationem, provident nemo ea distinctio dolor ullam ab facere blanditiis inventore debitis nobis vitae maxime suscipit accusantium.
</div>
</div>
<div class="cell">
<div class="cell-content">CELL2: lorem lorem lorem lorem </div>
</div>
</div>
</div>
CSS
.container {
display: table;
border: 2px solid red;
}
.row {
display: table-row;
}
.cell {
display: table-cell;
width: 30px;
border: 2px solid blue;
}
.cell-content{
max-height:200px; /* as per your requirement */
overflow:auto;
}

Columns with same height but various content length and a button on bottom

I am trying to set 3 columns in a row with same height. Everything works so far using flex and fixed height except that paragraph is cut out. Both the title and text could be of various length. Currently .btn-wrapper has padding-top which gives illusion of space around. Is there a way to fix that so that all letters are visible? It doesnt matter how paragraph ends, only that there is a space between button and the text.
Is there a better way to go around this?
http://codepen.io/anon/pen/QKbAwb?editors=1100
<div class="col col-md-4">
<div class="col-inside">
<p>Lorem ipsum..../p>
<div class="btn-wrapper">
Read more
</div>
</div>
</div>
.col {
display: flex;
}
.col-inside {
flex: 1;
flex-direction: column;
height: 200px;
overflow: hidden;
position: relative;
}
.btn-wrapper {
position: absolute;
bottom: 0;
width: 100%;
padding-top: 20px;
background-color: #fff;
}
Currently if the text is long it will be cut out like in this image
You don't need a fixed height, you need to extend the flex properties to the .row div.
This will automatically make all the columns the same height.
Oh and you don't need to position the button div either...flexbox can do that to.
.row {
display: flex;
}
.col {
padding: 0;
flex: 1;
display: flex;
flex-direction: column;
}
.col-inside {
border: 1px solid #999;
flex: 1;
display: flex;
margin: 0 10px;
flex-direction: column;
}
h2 {
margin-top: 0;
font-size: 26px;
font-weight: 600;
padding: 20px;
padding-bottom: 0;
}
.author {
font-style: italic;
font-size: 13px;
margin-bottom: 10px;
padding: 0 20px;
}
p {
padding: 0 20px;
}
.btn-wrapper {
margin-top: auto;
width: 100%;
padding-top: 20px;
background-color: #fff;
}
.btn.btn-default {
width: 100%;
display: block;
border-radius: 0;
background-color: grey;
color: #eee;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col col-md-4">
<div class="col-inside">
<img src="http://placehold.it/420x150" class="img-responsive" />
<h2>Some title</h2>
<div class="author">John Smith</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Qui obcaecati dolores at cupiditate ullam quaerat earum, quaerat earum, magni explicabo eveniet saepe! quaerat earum, magni explicabo eveniet saepe! magni explicabo eveniet saepe!</p>
<div class="btn-wrapper">
Read more
</div>
</div>
</div>
<div class="col col-md-4">
<div class="col-inside">
<img src="http://placehold.it/420x150" class="img-responsive" />
<h2>Some title longer Some title longer Some title longer Some title longer</h2>
<div class="author">John Smith</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Qui cupiditate quaerat earum, magni explicabo eveniet saepe!</p>
<div class="btn-wrapper">
Read more
</div>
</div>
</div>
<div class="col col-md-4">
<div class="col-inside">
<img src="http://placehold.it/420x150" class="img-responsive" />
<h2>Some title</h2>
<div class="author">John Smith</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.Qui obcaecati dolores at cupiditate ullam quaerat earum, magni explicabo eveniet saepe! amet, consectetur adipisicing elit. Qui obcaecati dolores Qui obcaecati dolores at cupiditate ullam
quaerat earum, magni explicabo eveniet saepe! quaerat earum, magni explicabo eveniet saepe! amet, consectetur adipisicing elit. Qui obcaecati dolores eveniet saepe! amet, consectetur adipisicing elit. Qui obcaecati dolores eveniet saepe! amet,
consectetur adipisicing elit. Qui obcaecati dolores</p>
<div class="btn-wrapper">
Read more
</div>
</div>
</div>
</div>
</div>
Codepen Demo