Flex columns equal header and content height - html

I made a row with columns in it, these columns need to have the same height. Inside these columns are a header and a main-content, the content in both these elements can vary, but I want the header to have the same height in all the columns. So the columns need to be the same height, but the header in these columns also need the same height.
Heres an example of the html:
.row{
display: flex;
}
.column{
display: flex;
flex-direction: column;
}
.header{
display: flex;
flex-direction: column;
align-items: center;
}
.header-content{
flex: 1 0 auto;
}
.main-content{
flex: 1 0 auto;
width: 100%;
float: left;
}
<ul class="row">
<li class="column">
<div class="header">
<div class="header-content">
<h2>Lorem ipsum dolor sit amet consectetur</h2>
<p>Toloribus, dolorem animi quo ea?</p>
</div>
Read more
</div>
<div class="main-content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nisi illum odio officiis optio quo esse, itaque ipsa velit, perspiciatis atque dignissimos. Beatae vero quas praesentium amet quos nemo, earum fugit.</p>
</div>
</li>
<li class="column">
<div class="header">
<div class="header-content">
<h2>Lorem ipsum dolor sit.</h2>
<p>Tenetur odio minus, quas natus.</p>
</div>
Read more
</div>
<div class="main-content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nisi illum odio officiis optio quo esse, itaque ipsa velit, perspiciatis atque dignissimos.</p>
</div>
</li>
</ul>

Flexbox cannot equalise heights between elements that do not share a parent (in fact no CSS layout method can). Since your headers do not, flexbox cannot help. You will need javascript (or a JS Library).
JQuery Sample Function
$(document).ready(function(){
var highestBox = 0;
$('.row .header').each(function(){
if($(this).height() > highestBox){
highestBox = $(this).height();
}
});
$('.row .header').height(highestBox);
});
$(document).ready(function() {
var highestBox = 0;
$('.row .header').each(function() {
if ($(this).height() > highestBox) {
highestBox = $(this).height();
}
});
$('.row .header').height(highestBox);
});
.row {
display: flex;
}
.column {
display: flex;
flex-direction: column;
}
.header {
display: flex;
flex-direction: column;
align-items: center;
background:#c0ffee;
}
.header-content {
flex: 1 0 auto;
}
.main-content {
flex: 1 0 auto;
width: 100%;
float: left;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul class="row">
<li class="column">
<div class="header">
<div class="header-content">
<h2>Lorem ipsum dolor sit amet consectetur</h2>
<p>Toloribus, dolorem animi quo ea?</p>
</div>
Read more
</div>
<div class="main-content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nisi illum odio officiis optio quo esse, itaque ipsa velit, perspiciatis atque dignissimos. Beatae vero quas praesentium amet quos nemo, earum fugit.</p>
</div>
</li>
<li class="column">
<div class="header">
<div class="header-content">
<h2>Lorem ipsum dolor sit.</h2>
<p>Tenetur odio minus, quas natus.</p>
</div>
Read more
</div>
<div class="main-content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nisi illum odio officiis optio quo esse, itaque ipsa velit, perspiciatis atque dignissimos.</p>
</div>
</li>
</ul>

Related

images with different size in stretch flexbox [duplicate]

This question already has answers here:
How can you set the height of an outer div to always be equal to a particular inner div?
(2 answers)
Closed 4 months ago.
I have align-items: stretch flexbox and inside this flexbox I have image and some text content.
text content is static and I need height of img to be as same as height of text content.
When I use different imgs with different aspect ratio I see different height on each img but I want the height of all images to be same.
*Please test snippet in fullscreen mode to see the problem
.card {
display: flex;
flex-direction: row;
align-items: stretch;
box-shadow: 0 0 20px 0px rgba(0, 0, 0, 0.1);
margin: 20px;
}
.title {
align-items: center;
display: flex;
flex-wrap: wrap;
font-size: 1.25rem;
font-weight: 700;
letter-spacing: 0.0125em;
line-height: 1.93rem;
word-break: break-all;
}
.title img {
object-fit: cover;
width: 150px;
height: 100%;
}
<div class="card">
<div class="title">
<img
src="https://s3-alpha-sig.figma.com/img/b579/835c/2b73668d5d42b127f5ed4e206c9c6576?Expires=1668384000&Signature=DoZ8O~AWDj6UhiZgP-5njh0zCqIk0ahZTAqvBVDjvyibc0seggNTv9lBjN-Xhkr6g0oiPnKyfGrqyhzfuPYN-S0T132EdQjEp1LH8FpNHmgBm1SyYVoxMQhnyCcsAF762M6~7lQ5SBqsujpbdmxwee6MChnRRrp706gkHXUYml3Mjd3kR7EsqViVjm39GTyW9DEPIer-qFBTQkILSGrkKjM-9zTitycyzO6c9no0PpclhAqpeeta0sz1JxmsSz7tVHQI9CoDLXWc0epbY7zcnhPqOKYqGkGf2~IS0S46x01CSvTDYIWj0dTt-vma4nOavEWShJhKBXwyjyk5VbQoHQ__&Key-Pair-Id=APKAINTVSUGEWH5XD5UA"
alt="alt"
/>
</div>
<div class="content">
<p class="text-caption grey3--text">2day ago</p>
<p class="text-subtitle-1 grey5--text font-weight-medium">some title</p>
<p class="ellipsis">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Id beatae
quia fugiat, minima eos fuga amet tenetur neque officia optio nulla
voluptatem ducimus dolores, cum animi tempore veritatis libero
repellat. Lorem ipsum dolor sit amet consectetur adipisicing elit. Id
beatae quia fugiat, minima eos fuga amet tenetur neque officia optio
</p>
</div>
</div>
<div class="card">
<div class="title">
<img
src="https://s3-alpha-sig.figma.com/img/bb5a/75f4/c083c0a5a79974bd94152c99b0f0d213?Expires=1668384000&Signature=Um5O0ddvXIROx5txgjSCEF1HcQVv2n6PVHdV81zu1KfaqIZUQw3qZDDgdBAjpnSPJ35-taxYHPLFlhV~tIPoxtJMlXFbJpihC6XIKaiyBUyuXJEicoLCm9fKm5UwbbFLJRU63MSHEDJWVYh8sTxAFaAEwNX~XoVgkfgN0c6ozOdImLOc0G8Hs3WYnDiURZ8jglC25XJRb9uPj7hiiL6tdCOWinA2F9uyLGtSxKHi~RU6ESMKgWOGpavQdeJ5M~iIRpkge2Ka2ySerfZh4184XLTxO8EUG-cin-lW7ncGcjiqLtDIXyt2PyQptpTIENAPMH7dSn1TvvpzjFbadavvnQ__&Key-Pair-Id=APKAINTVSUGEWH5XD5UA"
alt="alt"
/>
</div>
<div class="content">
<p class="text-caption grey3--text">2day ago</p>
<p class="text-subtitle-1 grey5--text font-weight-medium">some title</p>
<p class="ellipsis">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Id beatae
quia fugiat, minima eos fuga amet tenetur neque officia optio nulla
voluptatem ducimus dolores, cum animi tempore veritatis libero
repellat. Lorem ipsum dolor sit amet consectetur adipisicing elit. Id
beatae quia fugiat, minima eos fuga amet tenetur neque officia optio
</p>
</div>
</div>
if your text is going to contain the same line heights, you can use em measurements, 1em being 1 line of rem text size, if you plan on having different text contentss and line heights per span, you could also do this by having a class for each image, and then changing the height through those rather than a universal img tag, meaning you can change settings per image, rather than universally in your container.
.card {
display: flex;
flex-direction: row;
align-items: stretch;
box-shadow: 0 0 20px 0px rgba(0, 0, 0, 0.1);
margin: 20px;
}
.title {
align-items: center;
display: flex;
flex-wrap: wrap;
font-size: 1.25rem;
font-weight: 700;
letter-spacing: 0.0125em;
line-height: 1.93rem;
word-break: break-all;
}
.title > img {
object-fit: cover;
width: 150px;
height: 7.25em;
}
<div class="card">
<div class="title">
<img
src="https://s3-alpha-sig.figma.com/img/b579/835c/2b73668d5d42b127f5ed4e206c9c6576?Expires=1668384000&Signature=DoZ8O~AWDj6UhiZgP-5njh0zCqIk0ahZTAqvBVDjvyibc0seggNTv9lBjN-Xhkr6g0oiPnKyfGrqyhzfuPYN-S0T132EdQjEp1LH8FpNHmgBm1SyYVoxMQhnyCcsAF762M6~7lQ5SBqsujpbdmxwee6MChnRRrp706gkHXUYml3Mjd3kR7EsqViVjm39GTyW9DEPIer-qFBTQkILSGrkKjM-9zTitycyzO6c9no0PpclhAqpeeta0sz1JxmsSz7tVHQI9CoDLXWc0epbY7zcnhPqOKYqGkGf2~IS0S46x01CSvTDYIWj0dTt-vma4nOavEWShJhKBXwyjyk5VbQoHQ__&Key-Pair-Id=APKAINTVSUGEWH5XD5UA"
alt="alt"
/>
</div>
<div class="content">
<p class="text-caption grey3--text">2day ago</p>
<p class="text-subtitle-1 grey5--text font-weight-medium">some title</p>
<p class="ellipsis">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Id beatae
quia fugiat, minima eos fuga amet tenetur neque officia optio nulla
voluptatem ducimus dolores, cum animi tempore veritatis libero
repellat. Lorem ipsum dolor sit amet consectetur adipisicing elit. Id
beatae quia fugiat, minima eos fuga amet tenetur neque officia optio
</p>
</div>
</div>
<div class="card">
<div class="title">
<img
src="https://s3-alpha-sig.figma.com/img/bb5a/75f4/c083c0a5a79974bd94152c99b0f0d213?Expires=1668384000&Signature=Um5O0ddvXIROx5txgjSCEF1HcQVv2n6PVHdV81zu1KfaqIZUQw3qZDDgdBAjpnSPJ35-taxYHPLFlhV~tIPoxtJMlXFbJpihC6XIKaiyBUyuXJEicoLCm9fKm5UwbbFLJRU63MSHEDJWVYh8sTxAFaAEwNX~XoVgkfgN0c6ozOdImLOc0G8Hs3WYnDiURZ8jglC25XJRb9uPj7hiiL6tdCOWinA2F9uyLGtSxKHi~RU6ESMKgWOGpavQdeJ5M~iIRpkge2Ka2ySerfZh4184XLTxO8EUG-cin-lW7ncGcjiqLtDIXyt2PyQptpTIENAPMH7dSn1TvvpzjFbadavvnQ__&Key-Pair-Id=APKAINTVSUGEWH5XD5UA"
alt="alt"
/>
</div>
<div class="content">
<p class="text-caption grey3--text">2day ago</p>
<p class="text-subtitle-1 grey5--text font-weight-medium">some title</p>
<p class="ellipsis">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Id beatae
quia fugiat, minima eos fuga amet tenetur neque officia optio nulla
voluptatem ducimus dolores, cum animi tempore veritatis libero
repellat. Lorem ipsum dolor sit amet consectetur adipisicing elit. Id
beatae quia fugiat, minima eos fuga amet tenetur neque officia optio
</p>
</div>
</div>
You have to give height and width to the parent of img.
I have created a snippet for this.
.card {
display: flex;
flex-direction: row;
align-items: stretch;
box-shadow: 0 0 20px 0px rgba(0, 0, 0, 0.1);
margin: 20px;
}
.title {
width: 150px
}
.content{
width: calc(100% - 150px)
}
.title img {
object-fit: cover;
object-position: center;
width: 100%;
height: 100%;
}
<div class="card">
<div class="title">
<img src="https://s3-alpha-sig.figma.com/img/b579/835c/2b73668d5d42b127f5ed4e206c9c6576?Expires=1668384000&Signature=DoZ8O~AWDj6UhiZgP-5njh0zCqIk0ahZTAqvBVDjvyibc0seggNTv9lBjN-Xhkr6g0oiPnKyfGrqyhzfuPYN-S0T132EdQjEp1LH8FpNHmgBm1SyYVoxMQhnyCcsAF762M6~7lQ5SBqsujpbdmxwee6MChnRRrp706gkHXUYml3Mjd3kR7EsqViVjm39GTyW9DEPIer-qFBTQkILSGrkKjM-9zTitycyzO6c9no0PpclhAqpeeta0sz1JxmsSz7tVHQI9CoDLXWc0epbY7zcnhPqOKYqGkGf2~IS0S46x01CSvTDYIWj0dTt-vma4nOavEWShJhKBXwyjyk5VbQoHQ__&Key-Pair-Id=APKAINTVSUGEWH5XD5UA"
alt="alt" />
</div>
<div class="content">
<p class="text-caption grey3--text">2day ago</p>
<p class="text-subtitle-1 grey5--text font-weight-medium">some title</p>
<p class="ellipsis">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Id beatae quia fugiat, minima eos fuga amet tenetur neque officia optio nulla voluptatem ducimus dolores, cum animi tempore veritatis libero repellat. Lorem ipsum dolor sit amet consectetur adipisicing
elit. Id beatae quia fugiat, minima eos fuga amet tenetur neque officia optio
</p>
</div>
</div>
<div class="card">
<div class="title">
<img src="https://s3-alpha-sig.figma.com/img/bb5a/75f4/c083c0a5a79974bd94152c99b0f0d213?Expires=1668384000&Signature=Um5O0ddvXIROx5txgjSCEF1HcQVv2n6PVHdV81zu1KfaqIZUQw3qZDDgdBAjpnSPJ35-taxYHPLFlhV~tIPoxtJMlXFbJpihC6XIKaiyBUyuXJEicoLCm9fKm5UwbbFLJRU63MSHEDJWVYh8sTxAFaAEwNX~XoVgkfgN0c6ozOdImLOc0G8Hs3WYnDiURZ8jglC25XJRb9uPj7hiiL6tdCOWinA2F9uyLGtSxKHi~RU6ESMKgWOGpavQdeJ5M~iIRpkge2Ka2ySerfZh4184XLTxO8EUG-cin-lW7ncGcjiqLtDIXyt2PyQptpTIENAPMH7dSn1TvvpzjFbadavvnQ__&Key-Pair-Id=APKAINTVSUGEWH5XD5UA"
alt="alt" />
</div>
<div class="content">
<p class="text-caption grey3--text">2day ago</p>
<p class="text-subtitle-1 grey5--text font-weight-medium">some title</p>
<p class="ellipsis">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Id beatae quia fugiat, minima eos fuga amet tenetur neque officia optio nulla voluptatem ducimus dolores, cum animi tempore veritatis libero repellat. Lorem ipsum dolor sit amet consectetur adipisicing
elit. Id beatae quia fugiat, minima eos fuga amet tenetur neque officia optio
</p>
</div>
</div>

I am having a container which is flex and justified centre and aligned centre. when I create another flex item inside it space-between does not work

A container with flex and centered horizontally and vertically
I create two divs which are placed column wise
Now I have a third div which is given a flex with a row and needs to be displayed space between but space between does not work
here is the code
<style>
.flex{
width: 100vw;
height: 100vh;
border: 1px solid black;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.flex1,.flex2{
width: 300px;
border: 1px solid black;
}
.flex3{
display: flex;
justify-content: space-between;
}
</style>
<body>
<div class="flex">
<div class="flex1">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Recusandae alias dolorum cum sunt necessitatibus facere eveniet corrupti fugit fuga excepturi.</div>
<div class="flex2">Lorem ipsum dolor sit amet consectetur, adipisicing elit. Commodi vero iste voluptates, exercitationem voluptate cum id quo rem placeat nemo.</div>
<div class="flex3">
<div class="flex4">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Odio, cum.
</div>
<div class="flex5">
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Porro, nostrum.
</div>
</div>
</div>
</body>
.flex {
width: 100vw;
height: 100vh;
border: 1px solid black;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.flex1,
.flex2 {
width: 300px;
border: 1px solid black;
}
.flex3 {
display: flex;
justify-content: space-between;
}
<body>
<div class="flex">
<div class="flex1">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Recusandae alias dolorum cum sunt necessitatibus facere eveniet corrupti fugit fuga excepturi.</div>
<div class="flex2">Lorem ipsum dolor sit amet consectetur, adipisicing elit. Commodi vero iste voluptates, exercitationem voluptate cum id quo rem placeat nemo.</div>
<div class="flex3">
<div class="flex4">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Odio, cum.
</div>
<div class="flex5">
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Porro, nostrum.
</div>
</div>
</div>
</body>
Flex items are only as wide as their content by default, if align-items is something other than the default stretch. You need to give flex3 a width, presumably 100%.
.flex {
width: 100vw;
height: 100vh;
border: 1px solid black;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.flex1,
.flex2 {
width: 300px;
border: 1px solid black;
}
.flex3 {
width: 100%; /* <=== */
display: flex;
justify-content: space-between;
}
<div class="flex">
<div class="flex1">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Recusandae alias dolorum cum sunt necessitatibus facere eveniet corrupti fugit fuga excepturi.
</div>
<div class="flex2">Lorem ipsum dolor sit amet consectetur, adipisicing elit. Commodi vero iste voluptates, exercitationem voluptate cum id quo rem placeat nemo.
</div>
<div class="flex3">
<div class="flex4">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Odio, cum.
</div>
<div class="flex5">
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Porro, nostrum.
</div>
</div>
</div>

keep links same height when stacked in mobile regardless of text / content in the link

I have a row of links (bootstrap), in desktop, they are in columns across the screen but in mobile, they stack which is what I want. Right now they have a height of 100% and have equal heights in desktop regardless of the content in the link. My issue is how do I achieve the same equal heights in a mobile/stacked layout?
HTML:
<div class="container">
<div class="row">
<div class="col-md-4">
<a class="link equal-height" href="#">
<div>
<p class="link-text">
ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate facere illum, mollitia nam odit provident repellendus voluptas? A accusamus accusantium ad adipisci aliquam culpa debitis dolore doloremque ea eaque eos eum.
</p>
</div>
</a>
</div>
<div class="col-md-4">
<a class="link equal-height" href="#">
<div><p class="link-text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorem, doloribus.</p></div>
</a>
</div>
<div class="col-md-4">
<a class="link equal-height" href="#">
<div><p class="link-text"> Link Three</p></div>
</a>
</div>
</div>
css:
.link{
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: auto;
padding: 10px 15px;
}
.equal-heights{
height:100%
}
You can achieve this with a tiny bit of js
var maxHeight = 0;
$(".link").each(function(){
if ($(this).height() > maxHeight) { maxHeight = $(this).height(); }
});
$(".link").height(maxHeight);
ul {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 300px;
margin: 0 auto;
}
li {
list-style: none;
padding: .5rem 2rem;
background: DarkOrchid;
color: #fff;
margin: .5rem;
display: flex;
justify-content: center;
align-items: center;
align-self: stretch;
text-align: center;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ul class="links">
<li class="link">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Amet cumque ut nulla aliquid assumenda eos et est quis, impedit saepe pariatur eligendi iste, reiciendis odio doloremque eveniet quod distinctio molestias?</li>
<li class="link">link</li>
<li class="link">link</li>
<li class="link">link</li>
<li class="link">link</li>
</ul>
you can rewrite your layout with grid and use 1fr sizing.
POC:
.container {
display: grid;
grid-template-rows: 1fr 1fr 1fr
}
a {
display: block;
margin: 10px;
padding: 10px;
border: solid;
}
<div class="container">
<a>ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate facere illum, mollitia nam odit provident repellendus voluptas? A accusamus accusantium ad adipisci aliquam culpa debitis dolore doloremque ea eaque eos eum.</a>
<a>abc</a>
<a>ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate facere illum</a>
</div>
more info: https://css-tricks.com/snippets/css/complete-guide-grid/

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>

How to create a vertical line with a circles above it? (with example image)

I just wonder what is the idea by HTML and CSS?
You only need a css, a markup like that
<div class="circle-border">
<div class="circle-image">
<img ....>
</div>
</div>
and in css
.circle-border{
overflow:hidden;
border-radius:50%;
position:relative;
width: 200px; //for example
height:200px; //for example
}
.circle-image{
position:absolute;
top:0;
left:0;
border-radius:50%;
border:8px rbba(255,255,255,.6);
}
.circle-border img{
width:100%;
object-fit:cover;
}
With this you create the form, only need adjust the desing. Other and maybe simplest way is use a library like iHover, that provide you the design with awesome effects, probably helpfully for what you need.
For the vertical line, is no problem. you only need make "relative" the div where you have the images and the content, after, envolve the image markup in other div and set these div with absolute position and set the "top": 50% and margin-top: with the - pixels that the size of your circle image, set the left position with the same value. The HTML may be like that:
<article>
<section class="container-image">
<div class="circle-border">
<div class="circle-image">
<img ....>
</div>
</div>
<section class="content">
<!-- your content here-->
</section>
Oh! I know this one, I did this example myself some time ago. Probably not the best solution, but i used .class:after (so a vertical line that goes after a circle).
Then you write the usual stuff: content:''; background-color:#______; height; width.
To put it in the center you can use the position:relative, position:absolute, left:50%.
You could also use css animation to do that but since it is 1 or 2 px it wouldn't make a difference.
Hope it helps.
You can use CSS Flexbox. Have a look at my snippet:
.timeline-holder {
position: relative;
}
.timeline-holder:before {
content: '';
position: absolute;
top: 75px;
left: 50%;
transform: translateX(-50%);
width: 1px;
height: calc(100% - 75px);
background: #ccc;
z-index: -1;
}
.box {
display: flex;
align-items: center;
margin: 60px 0;
}
.box .text {
flex: 1;
padding: 0 20px;
}
.box img {
border-radius: 50%;
}
.box:nth-child(even) {
margin-right: calc(50% - 75px);
}
.box:nth-child(odd) {
flex-direction: row-reverse;
margin-left: calc(50% - 75px);
}
<div class="timeline-holder">
<div class="box">
<div class="text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Libero amet explicabo quis expedita fuga magnam consequatur perferendis aliquam ipsum odio magni illum aperiam, quod eaque, debitis consectetur, dolorem provident quidem.</div>
<img src="http://placehold.it/150x150" alt="" />
</div>
<div class="box">
<div class="text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Libero amet explicabo quis expedita fuga magnam consequatur perferendis aliquam ipsum odio magni illum aperiam, quod eaque, debitis consectetur, dolorem provident quidem.</div>
<img src="http://placehold.it/150x150" alt="" />
</div>
<div class="box">
<div class="text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Libero amet explicabo quis expedita fuga magnam consequatur perferendis aliquam ipsum odio magni illum aperiam, quod eaque, debitis consectetur, dolorem provident quidem.</div>
<img src="http://placehold.it/150x150" alt="" />
</div>
<div class="box">
<div class="text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Libero amet explicabo quis expedita fuga magnam consequatur perferendis aliquam ipsum odio magni illum aperiam, quod eaque, debitis consectetur, dolorem provident quidem.</div>
<img src="http://placehold.it/150x150" alt="" />
</div>
<div class="box">
<div class="text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Libero amet explicabo quis expedita fuga magnam consequatur perferendis aliquam ipsum odio magni illum aperiam, quod eaque, debitis consectetur, dolorem provident quidem.</div>
<img src="http://placehold.it/150x150" alt="" />
</div>
</div>
Hope this helps!