How to distributed unequal width items to fulfill the container with flexbox - css

I am having a requirement that displaying the dynamic unequal width items in a container but it needs to fulfill the parent container. The item is dynamic so we can not know how long it is. If there is no room in the row, we need to display that item in the next row but the existing rows must be distributed equally to fulfill the container's width. Something like this:
My expectation:
What I did is create a container with display: flex and put child items inside with their's width fit the content inside. The items can be displayed in the next row if there is no room for it but I have no clue how to distributed existing items to fulfill the whole row?
Code:
.container {
display: flex;
gap: 10px;
flex-wrap: wrap;
width: 350px;
border-style: dotted;
}
.item {
background-color: coral;
padding: 10px 1em;
margin: 5px;
}
<div class="container">
<div class="item">Lorem ipsum</div>
<div class="item">Lorem ipsum dolor</div>
<div class="item">adipiscing</div>
<div class="item">consectetur adipiscing elit</div>
<div class="item">Lorem ipsum dolor sit amet</div>
<div class="item">Lorem ipsum dolor</div>
</div>
I just wonder is there any flexbox's CSS property to solve this problem?

some extra CSS for the behavior of the content and the children could be used :
flex:1 0 auto;/* make it stretch as much as possible*/
max-width:calc(100% - 10px);/* do not let it be bigger than container width minus margin */
white-space: pre-wrap;/* keep on a single line as much as possible */
Possible demo
* {
box-sizing: border-box;
}
.container {
display: flex;
gap: 10px;/*NOTICE: understood by Firefox at the moment */
flex-wrap: wrap;
width: 350px;
border-style: dotted;
}
.item {
background-color: coral;
padding: 10px 1em;
margin: 5px;
/* update a few behaviors */
flex:1 0 auto;
max-width:calc(100% - 10px);/* 10px is right + left margin */
white-space: pre-wrap;
}
<div class="container">
<div class="item">Lorem ipsum</div>
<div class="item">Lorem ipsum dolor</div>
<div class="item">adipiscing</div>
<div class="item">consectetur adipiscing elit</div>
<div class="item">Lorem ipsum dolor sit amet</div>
<div class="item">Lorem ipsum dolor</div>
<div class="item">Lorem ipsum dolor</div>
<p class="item">Pellentesque habitant morbi tristique senectus et netus et netus et malesuada ac turpis egestas.</p>
</div>

Related

Can I have a responsive image with a set height?

I working in a page builder
For a shop, I am creating. I can change the CSS which is great.
I’m struggling to get a responsive resize of the images in this 4 column row. Since the images are different heights I have to have to set a height and have responsive width. Is there any way to get it to scale correctly?
The width is auto and the height is a set height based on the size of the screen.
You can see that when I resize it separates from the box and then sometimes get squished.
object-fit property
I did your design by using display : flex; and object-fit : cover; properties. I think that this object-fit property directly on the image is the only lacking property to make your images still looking good despite the screen resolution.
Notice the use of object-position : center; which makes the resizing always axed on the center of the image.
index.html
<div class="foo">
<div class="bar">
<img src="https://picsum.photos/200/300" alt="">
<div>
<h4>Lorem, ipsum dolor sit amet consectetur adipisicing.</h1>
<p>$42</p>
</div>
</div>
<div class="bar">
<img src="https://picsum.photos/500/200" alt="">
<div>
<h4>Lorem, ipsum dolor sit amet consectetur adipisicing.</h1>
<p>$42</p>
</div>
</div>
<div class="bar">
<img src="https://picsum.photos/200/700" alt="">
<div>
<h4>Lorem, ipsum dolor sit amet consectetur adipisicing.</h1>
<p>$42</p>
</div>
</div>
<div class="bar">
<img src="https://picsum.photos/500/400" alt="">
<div>
<h4>Lorem, ipsum dolor sit amet consectetur adipisicing.</h1>
<p>$42</p>
</div>
</div>
</div>
style.css
body {
background-color: #f7f7f7;
font-family: Arial, Helvetica, sans-serif;
}
.foo {
width: 100%;
display: flex;
gap: 20px;
}
.bar {
background-color: #ffffff;
display: flex;
flex-direction: column;
width: 100%;
border-radius: 15px;
overflow: hidden;
box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px;
}
.bar > img {
width: 100%;
height: 200px;
object-fit: cover;
object-position: center;
}
h4 {
color:#9ccf74;
}
.bar > div {
padding: 10px;
height: 100px;
}

lines with text around the Circle

How to make lines around the circle which holds text for each line. I don't want text to be in the pseudo class. Below is the required output Image
.
Below code is which I have tried from Paulie_D previous solutions
.outCircle {
width: 20px;
height: 20px;
background-color: lightblue;
position: relative;
border-radius: 50%;
margin: 100px auto;
}
.marker {
width: 50px;
height: 2px;
position: absolute;
top: 50%;
left: 50%;
background: linear-gradient(to right, black, black 25%, transparent 25%, transparent 75%, black 75%);
transform: translate(-50%, -50%);
}
.vert {
width: 2px;
height: 50px;
background: linear-gradient(to bottom, black, black 25%, transparent 25%, transparent 75%, red 75%);
transform: translate(-50%, -50%);
}
.angle-1 {
transform: translate(-50%, -50%) rotate(45deg);
}
.angle-2 {
transform: translate(-50%, -50%) rotate(-45deg);
}
.inner {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
<div class="outCircle">
<div class="inner">
<div class="marker horiz"></div>
<div class="marker vert"></div>
<div class="marker angle-1"></div>
<div class="marker angle-2"></div>
</div>
</div>
Unfortunately your question is not entirely clear, but my guess is that you want to create some info-graphic about seeds with text around a nice graphic.
Instead of focusing on showing you how to create bordered circles with CSS and place text around them, I removed the text from your original image and cropped it. Because, as I suggested in my comment to visit my answer on SO62815794, it made more sense to me to take that code and the cropped image and show you how to create a responsive info-graphic with Flexbox Layout and a media query.
If this is not what you meant, please modify your answer and be more specific about what you need. However, while it is fun to create a graphic with CSS, in terms of maintenance you would be much better off with a cropped image or SVG file (more graphical elements for creating custom shapes).
The Snippet
has two demos showing how to use Flexbox Layout combined with Custom Attributes to create responsively sizing 2D XxY grids with the cropped image in the center.
demo 1 is a fairly straightforward 3x3 flexbox grid with equally sized cells
demo 2 is more complicated and has a main 3x1 grid with nested 1x2, 1x3 and 1x2 child grids giving it a more 'circular feel' than demo 1
The snippet is heavily commented and should be self explanatory, but additionally:
I left your original .outCircle in the HTML, just disabled it.
the cropped image is 138x138px PNG file (11.4Kb), with a transparent background (alpha channel) so you can play with the info-graphic background-color (: White for now)
The #media considers anything smaller than 720px (W/H) to be a 'smartphone' and will neither show the image (or .outCircle) nor any grid layout.
All you need to do is some fine-tuning with spacing, colors and font-sizes.
Make sure to go 'Full page' on SO and resize the browser window.
/*************************************/
/* main page structure, MOBILE first */
/*************************************/
body { height: 100vh; background-color: White }
.main-structure {
display: flex; flex-flow: column wrap;
/* Center everything inside the element (vertical and horizontal) */
justify-content: center; align-content: center; align-items: center
/* add your specific mobile settings */
}
.main-structure .outCircle { display: none } /* don't show on mobile */
.main-structure img { display: none } /* ditto */
.main-structure ul { padding-right: 40px } /* [OPTIONAL] to make L/R padding equal */
/*************/
/* EYE-CANDY */
/*************/
[band*="header"] {
background-color: rgba(254,190,0,1); /* egg yolk-ish */
text-align: center
}
.main-structure .headline {
width: 100%; /* stretch to fill parent */
padding: .25em 1em; /* some inner spacing */
color: CornflowerBlue;
font-size: 1.25em; font-weight: bold;
}
.outCircle {
position: relative; /* creates a new 'stacking context' for child elements */
/* Center everything inside the element (vertical and horizontal) */
justify-content: center; align-content: center; align-items: center;
}
.inner {
position: absolute;
width : 1.25rem;
height: 1.25rem;
border-radius: 50%;
background-color: lightblue;
}
.marker {
position: absolute; /* direct positioning inside parent 'stacking context' */
width: 3rem; height: 0.125rem;
/* center element in parent */
top: 50%; left: 50%;
transform: translate(-50%, -50%);
background: linear-gradient(to right, black, black 25%, transparent 25%, transparent 75%, black 75%);
}
.vert {
width: 0.125rem; height: 3rem;
transform: translate(-50%, -50%);
background: linear-gradient(to bottom, black, black 25%, transparent 25%, transparent 75%, red 75%);
}
.angle-1 { transform: translate(-50%, -50%) rotate(45deg) }
.angle-2 { transform: translate(-50%, -50%) rotate(-45deg) }
/*****************************/
/* DESKTOP specific settings */
/*****************************/
#media (min-width: 720px) and (min-height: 720px) { /* anything larger than average mobile */
/* base flexbox patch grid structure */
[patch],[patch]>* { display: flex; flex-wrap: wrap } /* patch and cell containers */
[patch] { align-content: flex-start; position: relative }
[patch]>* { flex-grow: 1; /* [MANDATORY] */
overflow: hidden; /* [OPTIONAL] */
/* Center everything inside the element (vertical and horizontal) */
justify-content: center; align-content: center; align-items: center }
/* the "nine-patch", inspired by Android 9-patch image; essentially a 3x3 matrix */
[patch^= "3x"]>* { height : 33.33333%; max-height: 33.33333% } /* ^...starts with */
[patch*= "x3"]>* { flex-basis: 33.33333%; max-width : 33.33333% } /* *...contains */
[patch^= "1x"]>* { height: 100%; max-height: 100% } [patch*= "x1"]>* { flex-basis: 100%; max-width: 100% }
[patch^= "2x"]>* { height: 50%; max-height: 50% } [patch*= "x2"]>* { flex-basis: 50%; max-width: 50% }
/* add your own specific patch cell sizes like below */
/*
7x1 days in a week, 18x8 Periodic Table, 24x1 hours in a day, 22x6 keyboard+numpad, etc.
just divide 100% by the required XxY values
Usage:
<parent-tag patch="XxY">
requires X * Y number of child-tags to work properly
<child-tag 1>
....
<child-tag N>
</parent-tag>
*/
body { background-color: rgba(0,0,0,.1) } /* light grey */
.main-structure {
flex-flow: row wrap; /* we have 3 rows of several columns */
height: 75vmin; width: 75vmin; /* Modify to your needs */
background-color: White;
}
[band*="info2"] .main-structure>[patch="1x2"] {
max-width: 75%;
/* instead of 100%, this will move the cells closer for a 'circular feel' */
}
.main-structure img { display: block; width: 80% } /* Modify to your needs */
.main-structure .outCircle {
/* flex for easy centering of '.inner' */
display: flex; /* make visible */
}
}
/**************************/
/* preferred global rules */
/**************************/
html,body { width: 100%; max-width: 100% }
html { -webkit-box-sizing: border-box; box-sizing: border-box }
*, *:before, *:after { -webkit-box-sizing: inherit; box-sizing: inherit }
body { margin: 0 } /* remove default <body> spacing */
/*
Above CSS defines ALL elements to use 'border-box' (most common practice nowadays)
make sure to own the boxmodel knowledge!
MDN 'The box model': https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/The_box_model
w3schools 'CSS box-sizing Property': https://www.w3schools.com/cssref/css3_pr_box-sizing.asp
*/
/*
All math reference: https://www.mathsisfun.com/equation_of_line.html
*/
/* responsive base font size using y = mx + b */
html { font-size: calc(0.625vmin + 0.625rem) } /* (320,12)(1280,18) */
/* Simple banding attribute for use in 'Landing Page' layout */
[band] { display: flex; flex-flow: column wrap; align-content: center }
body[padded="1"],
body[padded="0"] [band*="padded"] {
/*
responsive page padding
and responsive band padding (same as responsive page padding, but at band level)
Top/Bottom padding: p1(320,16) p2(1920, 72) => 0.035x + 4.8 => vary from 16 to 72px
Left/Right padding: p3(320, 8) p4(1920,320) => 0.195x - 54.4 => vary from 8 to 320px
'Band padding' is only active when 'page padding' is off (0)
*/
padding: calc(3.5vh + 4.8px) calc(19.5vw - 54.4px);
}
/* for debugging (put in <body>) */
[outlines="1"] * { outline: 1px dotted }
<body outlines="0" padded="0">
<div band="padded.header">
<h1>3x3 easy grid with two dummies</h1>
<h3>easy, but straight columns</h3>
</div>
<div band="padded.info1">
<div class="main-structure" patch="3x3">
<div>
<div class="headline">Meet the farmer</div>
<ul>
<li>Lorem ipsum dolor sit amet, exerci dolorem est ad.</li>
<li>Lorem ipsum dolor sit amet, exerci dolorem est ad.</li>
</ul>
</div>
<div>
<div class="headline dummy"></div>
</div>
<div>
<div class="headline">Provenance</div>
<ul>
<li>Lorem ipsum dolor sit amet, exerci dolorem est ad.</li>
<li>Lorem ipsum dolor sit amet, exerci dolorem est ad.</li>
</ul>
</div>
<div>
<div class="headline">Certification</div>
<ul>
<li>Lorem ipsum dolor sit amet, exerci dolorem est ad.</li>
<li>Lorem ipsum dolor sit amet, exerci dolorem est ad.</li>
</ul>
</div>
<div>
<img src="https://i.postimg.cc/zvBCdxp4/circles.png">
</div>
<!--div class="outCircle">
<div class="inner">
<div class="marker horiz"></div>
<div class="marker vert"></div>
<div class="marker angle-1"></div>
<div class="marker angle-2"></div>
</div>
</div -->
<div>
<div class="headline">Life of the seed</div>
<ul>
<li>Lorem ipsum dolor sit amet, exerci dolorem est ad.</li>
<li>Lorem ipsum dolor sit amet, exerci dolorem est ad.</li>
</ul>
</div>
<div>
<div class="headline">History of seed</div>
<ul>
<li>Lorem ipsum dolor sit amet, exerci dolorem est ad.</li>
<li>Lorem ipsum dolor sit amet, exerci dolorem est ad.</li>
</ul>
</div>
<div>
<div class="headline dummy"></div>
</div>
<div>
<div class="headline">IoT data this seed season</div>
<ul>
<li>Lorem ipsum dolor sit amet, exerci dolorem est ad.</li>
<li>Lorem ipsum dolor sit amet, exerci dolorem est ad.</li>
</ul>
</div>
</div>
</div>
<div band="padded.header">
<h1>3x1 nested grid with 1x2, 1x3 and 1x2 child grids</h1>
<h3>more complicated, but has rows with a 'circular feel'</h3>
</div>
<div band="padded.info2">
<div class="main-structure" patch="3x1">
<div patch="1x2">
<div>
<div class="headline">Meet the farmer</div>
<ul>
<li>Lorem ipsum dolor sit amet, exerci dolorem est ad.</li>
<li>Lorem ipsum dolor sit amet, exerci dolorem est ad.</li>
</ul>
</div>
<div>
<div class="headline">Provenance</div>
<ul>
<li>Lorem ipsum dolor sit amet, exerci dolorem est ad.</li>
<li>Lorem ipsum dolor sit amet, exerci dolorem est ad.</li>
</ul>
</div>
</div>
<div patch="1x3">
<div>
<div class="headline">Certification</div>
<ul>
<li>Lorem ipsum dolor sit amet, exerci dolorem est ad.</li>
<li>Lorem ipsum dolor sit amet, exerci dolorem est ad.</li>
</ul>
</div>
<div>
<img src="https://i.postimg.cc/zvBCdxp4/circles.png">
</div>
<!--div class="outCircle">
<div class="inner">
<div class="marker horiz"></div>
<div class="marker vert"></div>
<div class="marker angle-1"></div>
<div class="marker angle-2"></div>
</div>
</div -->
<div>
<div class="headline">Life of the seed</div>
<ul>
<li>Lorem ipsum dolor sit amet, exerci dolorem est ad.</li>
<li>Lorem ipsum dolor sit amet, exerci dolorem est ad.</li>
</ul>
</div>
</div>
<div patch="1x2">
<div>
<div class="headline">History of seed</div>
<ul>
<li>Lorem ipsum dolor sit amet, exerci dolorem est ad.</li>
<li>Lorem ipsum dolor sit amet, exerci dolorem est ad.</li>
</ul>
</div>
<div>
<div class="headline">IoT data this seed season</div>
<ul>
<li>Lorem ipsum dolor sit amet, exerci dolorem est ad.</li>
<li>Lorem ipsum dolor sit amet, exerci dolorem est ad.</li>
</ul>
</div>
</div>
</div>
</div>
</body>
You could wrap it in a div and give the <div> the following styling:
#circle {
border: solid black 2px;
border-radius: 50%;
width: 10em; //Depends on the circles size..
height: 10em;
}

How can I display 2 items in a flex container and keep set width and height of a flex item?

*I have added padding inside the divs so you're able to see the boxes
I need to display these 2 items next to each other on desktop screen sizes.
I the purple bordered box which contains the 2 elements is set to display flex.
The circle div sqaushes up.
I have set is to a height: 200px width: 200px - this is fine before I set the parent to display flex.
How can I make sure that the circle stays at the set width and height and the rest of the content in the red box resizes - rather than the other way around?
If you could also please explain like I'm 5 why this is happening that would be really appreciated.
.card__inner {
display: flex;
}
.news__feature-image {
border-radius: 100%;
width: 200px;
height: 200px;
background: red;
}
<article class="card">
<div class="card__inner">
<div class="news__feature-image"></div>
<div class="card__content">
<header class="news__header">
<span class="new__post-date">
18 Sep
</span>
<a class="card__link" href="/">
Read More
</a>
</header>
<h2 class="news__title">Lorem ipsum title this is a title etc Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed turpis est, eleifend.</h2>
</div>
</div>
</article>
I have tried using flex grow and flex shrink on the feature image and the content.
I have added settings for the flex items that contains the circle. By default the setting for flex-shrink is 1, which allows it to shrink if necessary. Setting it to zero ensures the circle is displayed as desired.
* {
box-sizing: border-box;
}
.container {
border: thin solid green;
padding: 1rem;
}
.inner {
border: thin solid purple;
display: flex;
padding: 1rem;
}
.circle {
width: 200px;
height: 200px;
background-color: red;
border-radius: 100%;
flex-shrink: 0;
}
<div class="container">
<div class="inner">
<div class="circle"></div>
<div class="text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>
</div>
</div>

Vertically align elements in different height columns

I've attached an illustration to help me get my point across!
So, DIV 1 and DIV 2 (children of PARENT DIV) are columns on a page I'm building, and the content within them is not of the same height, so currently their buttons do not line up vertically.
I need to vertically align BUTTON 1 and BUTTON 2 (I guess to the bottom of PARENT DIV?);
How do I go about this please?
Thanks!
I don't think you can get away from the position CSS directive, but if you don't want to use bottom, there are numerous jQuery examples that will allow you to logically place your divs.
Alternately (and I know you seem to want to use Divs) but you may be able to use a table easier.
You can apply position relative and a bottom padding in DIV 1 and DIV 2 to prevent its content to overlap the buttons, whose position should be absolute (maybe bottom: 10px according to your screenshot).
Example: jsfiddle.net/yy87qdmt/1/
Tested & proofed in firefox-45 and chrome-50
<body>
<main>
<style scoped>
main
{
flex-direction: row;
display: flex;
}
main > figure
{
border: 1px darkgrey solid;
justify-content: flex-end;
flex-direction: column;
box-sizing: border-box;
display: flex;
}
main > figure > :first-child
{
background-color: lightgrey;
flex-grow: 1;
}
main > figure > figcaption
{
background-color: black;
color: lightgrey;
flex-shrink: 1;
}
</style>
<figure>
<picture>
<source srcset="mdn-logo-wide.png" media="(min-width: 600px)">
<img src="mdn-logo-narrow.png" alt="MDN">
</picture>
<figcaption>
Caption 0
</figcaption>
</figure>
<figure>
<article>
<p>Lorem ipsum dolor sit amet cosectetur...</p>
<p>...Lorem ipsum dolor sit amet cosectetur...</p>
<p>...Lorem ipsum dolor sit amet cosectetur</p>
</article>
<figcaption>
Caption 1
</figcaption>
</figure>
</main>
</body>
Flexbox can do that.
.row {
display: flex;
width: 80%;
margin: auto;
}
.col {
width: 50%;
border: 1px solid grey;
text-align: center;
padding: 1em;
}
img {
width: auto;
max-height: 100%;
}
p {
text-align: justify;
}
/* the magic */
.col {
display: flex;
flex-direction: column;
}
button {
margin-top: auto;
}
<div class="row">
<div class="col">
<h2>My Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequuntur, dignissimos.</p>
<button>My button</button>
</div>
<div class="col">
<h2>My Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestiae excepturi autem laborum veritatis ipsam odio itaque, dolorem modi ipsum voluptatibus. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Atque assumenda error blanditiis aliquam
repellendus, necessitatibus doloribus ipsa eveniet natus laborum.</p>
<button>My button</button>
</div>
</div>

flexbox vertically split container in HALF

Can anyone tell how can I make right top container and right bottom container to have the same height and to split the red container 50-50% vertically. No matter what is the content inside. I tried stretching content and have them wrapped while keeping flex-direction: row to keep same height for items but I'm lost.
What I expect: right top container grows the same height as right bottom which also results the left container growing automatically of course.
This is what I have so far: http://jsbin.com/rozoxoneki/edit?html,css,output
.flex{
display: flex;
border: 5px solid red;
&-child{
background: green;
border: 2px solid yellow;
flex: 1;
}
}
.flex--vertical{
flex-direction: row;
flex-wrap: wrap;
> .flex-child{
min-width: 100%;
}
}
<div class="flex">
<div class="flex-child">
left
</div>
<div class="flex-child flex flex--vertical">
<div class="flex-child">
<h1>right top</h1>
</div>
<div class="flex-child">
<h1>right bottom</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusantium autem esse iste voluptate eum ex mollitia temporibus unde eveniet omnis, vel, corrupti sed nobis consequatur quaerat ad sequi aliquid nostrum?</p>
</div>
</div>
</div>
The accepted answer is not ideal for the use of flex properties, because it can all be done without the need for min-height or max-height
I've cleaned up the example fiddle and removed non-essential css styles to show which flex properties are being used here.
In order to get evenly spaced top/bottom divs, you need to either specify the proper value for flex-basis, or let flex work itself out. Assuming that the parent's display is set to flex with a column orientation, the combined flex style can get us there easily:
.half-containers {
flex: 1;
}
see more on flex styling and the flex-basis property
Intuitively one would expect that this would work just with a flex-direction: column for the main container and the left container's height set to 100%.
Instead all browser do this: (this is a quote from another stackoverflow question)
How is it possible that all major browsers got the flex container to
expand on wrap in row-direction but not in column-direction?
So what you can do is wrap the two right containers into a new one:
Like this HTML - schema:
<div class="main-container">
<div class="left-container">Left container</div>
<div class="right-container">
<div class="half-containers">Top right</div>
<div class="half-containers">Bottom right</div>
</div>
</div>
Here is a jsfiddle as an example how you could style it for the expected result.
In this example the 'main-container' is set to 50% width and 75% height of the body.
Building on Felipe's answer, here is an even more minimal example of how to split a single flex container in half vertically. Each of these styles has been confirmed to be significant and necessary, except for the two at the bottom marked optional.
(What got me was that every parent element needs to have a height: 100% set, or the whole thing breaks.)
HTML
<div id="container">
<div class="row">This is the top.</div>
<div class="row">This is the bottom.</div>
</div>
CSS
html, body {
height: 100%;
}
#container {
display: flex;
flex-direction: column;
height: 100%;
}
.row {
flex: 1;
}
/* optional: get rid of body margin. makes look nice. */
body {
margin: 0;
}
/* optional: shade the bottom row */
.row:nth-child(2) {
background: #bbb
}
Working CodePen here:
https://codepen.io/rbrtmrtn/pen/NyxeJE
we can use flexbox concepts to split equally between two div with the parent in the following way
* {
width: auto;
height: 100%;
}
.row {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.col {
flex: 1;
margin: 5px;
border: solid;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Other page</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
</head>
<body>
<div class="row">
<div class="col">
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
</div>
<div class="col">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad omnis quae
expedita ipsum nobis praesentium velit animi minus amet perspiciatis
laboriosam similique debitis iste ratione nemo ea at corporis aliquam.
</div>
</div>
</body>
</html>

Resources