Can't apply overflow in a flexbox [duplicate] - html

This question already has answers here:
Why don't flex items shrink past content size?
(5 answers)
Closed 9 months ago.
I'm struggling to make overflow-y works within flex.
<div class="flex h-full flex-col">
<mark class="bg-red-900 p-2 font-semibold text-white"> Warning message </mark>
<main class="flex flex-1 bg-green-100">
<div class="flex flex-[4] bg-slate-100">
<div class="flex flex-col bg-slate-200">
<button variant="ghost">Filter</button>
<button variant="ghost">Filter</button>
<button variant="ghost">Filter</button>
<button variant="ghost">Filter</button>
</div>
<div class="flex flex-1 flex-col bg-slate-400">
<div class="flex flex-row-reverse border-y p-2">
<h2 class="flex items-center font-black">F0KLM</h2>
<div class="flex flex-1 flex-col">
<span class="text-sm">User</span>
<span class="text-sm">11:30</span>
</div>
</div>
</div>
</div>
<div class="flex min-h-0 flex-[7] flex-col bg-red-100">
<div class="flex items-center justify-between p-4">
<div class="flex gap-4">
<h1 class="font-black">F0KLM</h1>
<BadgeStatus status={"new"} />
</div>
<div class="rounded-md bg-black p-2 text-white">11:24</div>
</div>
<div class="mx-4 flex flex-1 flex-col gap-2 overflow-y-auto bg-white">
<div class="rounded-md border p-2">Header</div>
<div class="rounded-md border p-2">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. At erat pellentesque adipiscing commodo elit at imperdiet. Vulputate mi sit amet mauris commodo quis imperdiet massa tincidunt. Feugiat in fermentum posuere urna nec tincidunt praesent semper feugiat. Arcu felis bibendum ut tristique et egestas quis ipsum.</p>
Pharetra
<p>sit amet aliquam id diam. Tellus mauris a diam maecenas sed enim ut. Sed faucibus turpis in eu. Neque ornare aenean euismod elementum nisi quis eleifend. In nulla posuere sollicitudin aliquam ultrices sagittis orci a. Non quam lacus suspendisse faucibus interdum posuere lorem ipsum dolor. Eget magna fermentum iaculis eu. Elementum eu facilisis sed odio. Turpis egestas sed tempus urna et pharetra pharetra massa massa. Nunc lobortis mattis aliquam faucibus. Leo integer malesuada nunc vel risus commodo.</p>
</div>
<div class="rounded-md border p-2">Info</div>
</div>
<div class="flex justify-end gap-4 p-4">
<button variant="ghost">Ok</button>
<button variant="ghost">Reject</button>
</div>
</div>
</main>
<nav class="flex justify-around bg-white py-2">
<button variant="ghost">Button</button>
<button variant="ghost">Button</button>
<button variant="ghost">Button</button>
<button variant="ghost">Button</button>
</nav>
</div>
https://play.tailwindcss.com/FPDpxYXCTV
What I'd like to achieve is to have a scroll when the white div is overflowing, so the rest stay in place (full screen interface for iPad).
I've been trying to apply min-h-0 (min-height: 0;) on the parent div as suggested in numerous post, but it doesn't work..
Any help would be greatly appreciated!

One should add min-h-0 to <main>.. I swear I tried everything.

Add overflow-y-scroll h-3/5 to the div containing the paragraphs.
Please find below the solution code and watch result in full screen.
<script src="https://cdn.tailwindcss.com" ></script>
<div class="flex h-full flex-col">
<mark class="bg-red-900 p-2 font-semibold text-white"> Warning message </mark>
<main class="flex flex-1 bg-green-100">
<div class="flex flex-[4] bg-slate-100">
<div class="flex flex-col bg-slate-200">
<button variant="ghost">Filter</button>
<button variant="ghost">Filter</button>
<button variant="ghost">Filter</button>
<button variant="ghost">Filter</button>
</div>
<div class="flex flex-1 flex-col bg-slate-400">
<div class="flex flex-row-reverse border-y p-2">
<h2 class="flex items-center font-black">F0KLM</h2>
<div class="flex flex-1 flex-col">
<span class="text-sm">User</span>
<span class="text-sm">11:30</span>
</div>
</div>
</div>
</div>
<div class="flex min-h-0 flex-[7] flex-col bg-red-100">
<div class="flex items-center justify-between p-4">
<div class="flex gap-4">
<h1 class="font-black">F0KLM</h1>
<BadgeStatus status={"new"} />
</div>
<div class="rounded-md bg-black p-2 text-white">11:24</div>
</div>
<div class="mx-4 flex flex-1 flex-col gap-2 overflow-y-auto bg-white">
<div class="rounded-md border p-2">Header</div>
<div class="rounded-md border p-2 overflow-y-scroll h-3/5">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
labore et dolore magna aliqua. At erat pellentesque adipiscing commodo elit at imperdiet.
Vulputate mi sit amet mauris commodo quis imperdiet massa tincidunt. Feugiat in fermentum
posuere urna nec tincidunt praesent semper feugiat. Arcu felis bibendum ut tristique et
egestas quis ipsum.</p>
Pharetra
<p>sit amet aliquam id diam. Tellus mauris a diam maecenas sed enim ut. Sed faucibus turpis in
eu. Neque ornare aenean euismod elementum nisi quis eleifend. In nulla posuere sollicitudin
aliquam ultrices sagittis orci a. Non quam lacus suspendisse faucibus interdum posuere lorem
ipsum dolor. Eget magna fermentum iaculis eu. Elementum eu facilisis sed odio. Turpis egestas
sed tempus urna et pharetra pharetra massa massa. Nunc lobortis mattis aliquam faucibus. Leo
integer malesuada nunc vel risus commodo.</p>
<p>sit amet aliquam id diam. Tellus mauris a diam maecenas sed enim ut. Sed faucibus turpis in
eu. Neque ornare aenean euismod elementum nisi quis eleifend. In nulla posuere sollicitudin
aliquam ultrices sagittis orci a. Non quam lacus suspendisse faucibus interdum posuere lorem
ipsum dolor. Eget magna fermentum iaculis eu. Elementum eu facilisis sed odio. Turpis egestas
sed tempus urna et pharetra pharetra massa massa. Nunc lobortis mattis aliquam faucibus. Leo
integer malesuada nunc vel risus commodo.</p>
<p>sit amet aliquam id diam. Tellus mauris a diam maecenas sed enim ut. Sed faucibus turpis in
eu. Neque ornare aenean euismod elementum nisi quis eleifend. In nulla posuere sollicitudin
aliquam ultrices sagittis orci a. Non quam lacus suspendisse faucibus interdum posuere lorem
ipsum dolor. Eget magna fermentum iaculis eu. Elementum eu facilisis sed odio. Turpis egestas
sed tempus urna et pharetra pharetra massa massa. Nunc lobortis mattis aliquam faucibus. Leo
integer malesuada nunc vel risus commodo.</p>
</div>
<div class="rounded-md border p-2">Info</div>
</div>
<div class="flex justify-end gap-4 p-4">
<button variant="ghost">Ok</button>
<button variant="ghost">Reject</button>
</div>
</div>
</main>
<nav class="flex justify-around bg-white py-2">
<button variant="ghost">Button</button>
<button variant="ghost">Button</button>
<button variant="ghost">Button</button>
<button variant="ghost">Button</button>
</nav>
</div>

Related

How to align cards in carousel - Bootstrap 5?

I have simple Bootstrap 5 cards in carousel. When the card has less text the height on the card is getting smaller, and the carousel is jumping while sliding.
How can I stretch the cards to be the same height as the highest card, without using fixed values?
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<div id="demo" class="carousel slide" data-bs-ride="carousel" style="background-color:powderblue;">
<!-- The slideshow/carousel -->
<div class="carousel-inner">
<div class="carousel-item active">
<div class="container mt-3">
<h2>Basic Card 1</h2>
<div class="card">
<div class="card-body">Basic card</div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed facilisis ac justo
eget congue. Quisque commodo dignissim commodo. Vivamus feugiat quam id urna
tempor, a rhoncus libero sollicitudin. Vivamus scelerisque tortor ac elit fringilla
cursus. Suspendisse vitae dui sapien. Suspendisse at metus sed lacus faucibus
dictum. Nam mollis, ex id viverra fermentum, mauris lectus sodales erat, vitae
fringilla risus leo nec magna. Mauris luctus iaculis pretium. Nullam elit mi,
laoreet a felis ut, ullamcorper maximus nibh. Donec non dolor eu lectus condimentum
consectetur. Vivamus venenatis hendrerit nulla quis vestibulum.</p>
</div>
</div>
</div>
<div class="carousel-item">
<div class="container mt-3">
<h2>Basic Card 2</h2>
<div class="card">
<div class="card-body">Basic card</div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed facilisis ac justo eget
congue. Quisque commodo dignissim commodo. Vivamus feugiat quam id urna tempor, a
rhoncus libero sollicitudin. Vivamus scelerisque tortor ac elit fringilla cursus.
Suspendisse vitae dui sapien. Suspendisse at metus sed lacus faucibus dictum. Nam
mollis, ex id viverra fermentum, mauris lectus sodales erat, vitae fringilla risus leo
nec magna. Mauris luctus iaculis pretium. Nullam elit mi, laoreet a felis ut,
ullamcorper maximus nibh. Donec non dolor eu lectus condimentum consectetur. Vivamus
venenatis hendrerit nulla quis vestibulum. In rhoncus purus sit amet urna luctus
finibus. Nulla varius imperdiet sem, vel lacinia purus elementum id.</p>
</div>
</div>
</div>
<div class="carousel-item">
<div class="container mt-3">
<h2>Basic Card 3</h2>
<div class="card">
<div class="card-body">Basic card</div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed facilisis ac justo eget congue. Quisque commodo dignissim commodo. Vivamus feugiat quam id urna tempor, a rhoncus libero sollicitudin. .</p>
</div>
</div>
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#demo" data-bs-slide="prev">
<span class="carousel-control-prev-icon"></span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#demo" data-bs-slide="next">
<span class="carousel-control-next-icon"></span>
</button>
</div>
```
I've created some CSS to adjust BS5 slider to make it work with slides, that have different height.
Also, I've updated card's structure according to BS5 docs:
card-title
card-text
I understand it's just example, but anyway, I did it just for better looking.
Take a look at comments I added to CSS part for more details.
/* updated carousel element to add gaps around cards */
.carousel {
background-color: powderblue;
padding-top: 1rem;
padding-bottom: 1rem;
}
/* make inner block flex to stretch slides */
.carousel-inner {
display: flex;
}
/* make flex item to stretch parent container to max child height */
.carousel-item {
display: flex !important;
/* animate carousel item opacity property */
opacity: 0;
transition: transform .6s ease-in-out, opacity .3s ease-in-out !important;
}
/* animate carousel item opacity property */
.carousel-item.active {
opacity: 1;
z-index: 1;
}
.carousel-item-start,
.carousel-item-next {
opacity: 1;
}
/* end of animating of opacity */
/* added for example purpose (make arrows darker) */
.carousel-control-prev-icon,
.carousel-control-next-icon {
filter: brightness(0);
}
/* adjusting (stretching) slide's card to max height */
.carousel-item .container {
display: flex;
flex-direction: column;
}
.carousel-item .card {
flex-grow: 1;
}
/* end of adjusting */
/* play around this classes to animate it like you want */
/*
.carousel-item-end
.carousel-item-next
.carousel-item-prev
.carousel-item-start
*/
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<div id="demo" class="carousel slide" data-bs-ride="carousel">
<!-- The slideshow/carousel -->
<div class="carousel-inner">
<div class="carousel-item active">
<div class="container mt-3">
<h2>Basic Card 1</h2>
<div class="card">
<div class="card-body">
<h5 class="card-title">Basic card</h5>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed facilisis ac justo eget congue. Quisque commodo dignissim commodo. Vivamus feugiat quam id urna tempor, a rhoncus libero sollicitudin. Vivamus scelerisque tortor ac elit fringilla
cursus. Suspendisse vitae dui sapien. Suspendisse at metus sed lacus faucibus dictum. Nam mollis, ex id viverra fermentum, mauris lectus sodales erat, vitae fringilla risus leo nec magna. Mauris luctus iaculis pretium. Nullam elit mi, laoreet
a felis ut, ullamcorper maximus nibh. Donec non dolor eu lectus condimentum consectetur. Vivamus venenatis hendrerit nulla quis vestibulum.</p>
</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="container mt-3">
<h2>Basic Card 2</h2>
<div class="card">
<div class="card-body">
<h5 class="card-title">Basic card</h5>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed facilisis ac justo eget congue. Quisque commodo dignissim commodo. Vivamus feugiat quam id urna tempor, a rhoncus libero sollicitudin. Vivamus scelerisque tortor ac elit fringilla
cursus. Suspendisse vitae dui sapien. Suspendisse at metus sed lacus faucibus dictum. Nam mollis, ex id viverra fermentum, mauris lectus sodales erat, vitae fringilla risus leo nec magna. Mauris luctus iaculis pretium. Nullam elit mi, laoreet
a felis ut, ullamcorper maximus nibh. Donec non dolor eu lectus condimentum consectetur. Vivamus venenatis hendrerit nulla quis vestibulum. In rhoncus purus sit amet urna luctus finibus. Nulla varius imperdiet sem, vel lacinia purus elementum
id.
</p>
</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="container mt-3">
<h2>Basic Card 3</h2>
<div class="card">
<div class="card-body">
<h5 class="card-title">Basic card</h5>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed facilisis ac justo eget congue. Quisque commodo dignissim commodo. Vivamus feugiat quam id urna tempor, a rhoncus libero sollicitudin. .</p>
</div>
</div>
</div>
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#demo" data-bs-slide="prev">
<span class="carousel-control-prev-icon"></span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#demo" data-bs-slide="next">
<span class="carousel-control-next-icon"></span>
</button>
</div>

how to use scrollspy in bootstrap4?

I am new to html/bootstrap/css.
I'm trying to make scrollspy in a list on a website page that I'm currently working on (essentially, I'm only modifying HTML produced by R postcards package).
Here is my HTML code. This file uses bootstrap 3.4.1, I can't replicate the expected behavior with bootstrap 4. When I do use <script> with a newer version of Bootstrap (say 4.5.0) the buttons/list items (li)/links do not seem to be active anymore as I scroll through the page.
I'm not sure why this code does not run as expected using newer versions of bootstrap.
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.0/dist/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/jquery#3.5.1/dist/jquery.slim.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<link href="https://fonts.googleapis.com/css2?family=Roboto+Slab&display=swap" rel="stylesheet">
<style type="text/css">
body {font-family: 'Roboto Slab', serif;}
div.my-5 div {height: 500px;}
li.active>a>button {background-color: #343a40;color: #fff;}
</style>
<title>Frank Hermosillo</title>
</head>
<body>
<div class="container-fluid d-none d-lg-block d-xl-block">
<div class="d-flex row flex-row vh-100">
<div class="d-flex flex-column col-5 align-items-center text-center align-self-center">
<div class="mx-auto text-center">
<div class="p-3">
<img src="https://upload.wikimedia.org/wikipedia/en/thumb/8/80/Wikipedia-logo-v2.svg/1200px-Wikipedia-logo-v2.svg.png" style="height:15rem" class="rounded">
</div>
<div class="p-2">
<h1>Frank Hermosillo</h1>
</div>
<hr style="width:60%;" />
<div class="p-2">
<div id="icon-list">
<div id="myScrollspy">
<ul class="list-inline nav">
<li class="list-inline-item">
<a href="#bio">
<button type="button" class="btn btn-outline-dark mb-2">
Bio
</button>
</a>
</li>
<li class="list-inline-item">
<a href="#education">
<button type="button" class="btn btn-outline-dark mb-2">
Educ
</button>
</a>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="d-flex flex-column vh-100 border-left"></div>
<div class="d-flex flex-column col px-5 align-items-center align-self-center mh-100" style="overflow-y: scroll;" data-spy="scroll" data-target="#myScrollspy">
<div class="my-5" id="content">
<div id="bio" class="section level2">
<h2>Bio</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sodales cursus ante, ut iaculis diam euismod nec. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nam ut felis a nisl viverra sollicitudin. Vestibulum quis elementum libero. Suspendisse pellentesque justo dui, at consectetur turpis vulputate eget. Maecenas lacus tortor, tempus eu magna ac, maximus tincidunt est. Proin vitae lacus sollicitudin, lobortis orci vitae, fringilla ex. Nullam vestibulum neque sapien, id dapibus augue molestie ac. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Proin non ante leo. Pellentesque id massa nisi. Maecenas at facilisis velit. Nunc in purus in nisi consectetur bibendum. Etiam mattis eros ante, eget suscipit lectus tincidunt sit amet. Aliquam sed suscipit dui. Nulla non tristique sem.</p>
<p>Link text Here</p>
</div>
<div id="education" class="section level2">
<h2>Education</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sodales cursus ante, ut iaculis diam euismod nec. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nam ut felis a nisl viverra sollicitudin. Vestibulum quis elementum libero. Suspendisse pellentesque justo dui, at consectetur turpis vulputate eget. Maecenas lacus tortor, tempus eu magna ac, maximus tincidunt est. Proin vitae lacus sollicitudin, lobortis orci vitae, fringilla ex. Nullam vestibulum neque sapien, id dapibus augue molestie ac. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Proin non ante leo. Pellentesque id massa nisi. Maecenas at facilisis velit. Nunc in purus in nisi consectetur bibendum. Etiam mattis eros ante, eget suscipit lectus tincidunt sit amet. Aliquam sed suscipit dui. Nulla non tristique sem.</p>
</div>
</div>
</div>
</div>
</div>
<div class="container-flex min-vh-100 d-block d-lg-none d-xl-none">
<div class="d-flex flex-row justify-content-center">
<div class="d-flex flex-col">
<div class="mx-auto">
<div class="p-3 mt-3 text-center">
<img src="https://upload.wikimedia.org/wikipedia/en/thumb/8/80/Wikipedia-logo-v2.svg/1200px-Wikipedia-logo-v2.svg.png" style="height:15rem" class="rounded">
</div>
<div class="p-2 text-center">
<h1>Frank Hermosillo</h1>
</div>
<hr style="width:60%;" />
<div class="row justify-content-center align-items-center">
<div class="col-8 p-1 text-center">
<div class="list-group">
<a href="#bio">
<button type="button" class="list-group-item list-group-item-action my-1 rounded">
Bio
</button>
</a>
<a href="#education">
<button type="button" class="list-group-item list-group-item-action my-1 rounded">
Educ
</button>
</a>
</div>
</div>
</div>
<div class="p pt-4 px-5">
<div id="bio" class="section level2">
<h2>Bio</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sodales cursus ante, ut iaculis diam euismod nec. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nam ut felis a nisl viverra sollicitudin. Vestibulum quis elementum libero. Suspendisse pellentesque justo dui, at consectetur turpis vulputate eget. Maecenas lacus tortor, tempus eu magna ac, maximus tincidunt est. Proin vitae lacus sollicitudin, lobortis orci vitae, fringilla ex. Nullam vestibulum neque sapien, id dapibus augue molestie ac. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Proin non ante leo. Pellentesque id massa nisi. Maecenas at facilisis velit. Nunc in purus in nisi consectetur bibendum. Etiam mattis eros ante, eget suscipit lectus tincidunt sit amet. Aliquam sed suscipit dui. Nulla non tristique sem.</p>
<p>Link text Here</p>
</div>
<div id="education" class="section level2">
<h2>Education</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sodales cursus ante, ut iaculis diam euismod nec. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nam ut felis a nisl viverra sollicitudin. Vestibulum quis elementum libero. Suspendisse pellentesque justo dui, at consectetur turpis vulputate eget. Maecenas lacus tortor, tempus eu magna ac, maximus tincidunt est. Proin vitae lacus sollicitudin, lobortis orci vitae, fringilla ex. Nullam vestibulum neque sapien, id dapibus augue molestie ac. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Proin non ante leo. Pellentesque id massa nisi. Maecenas at facilisis velit. Nunc in purus in nisi consectetur bibendum. Etiam mattis eros ante, eget suscipit lectus tincidunt sit amet. Aliquam sed suscipit dui. Nulla non tristique sem.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
First of all, to add scroll spy to your site you need to add in your body tag as following: <body> data-spy="scroll" data-target="[class of the target]" data-offset="[can be any value, depending on your likings]">. You also need a place where the links should be updated, a navbar for example, (noted in the code above with [class of the target]). In your navbar, there should be <a> tags that link to the section id, for example My link.
You can also add custom styling to the links when they are active like here: a:active { //the active style }.

Bootstrap columns and justify-content-end

I'm having difficulty getting my columns to spread out.
According to the docs (https://getbootstrap.com/docs/5.0/layout/columns/#horizontal-alignment), justify-content-between should be what I need.
But I end up with my columns in their default position, not pushed outwards.
Basic code example:
https://codepen.io/6a0a49af-a3f9-4e78-8ccf-91d8d1b1f102/pen/QWKYJqM
I have changed your code a little to get the desired effect.
On <div class="row"> i removed some unneeded styles.
and on the <div class="col"> i changed it to col-4 to set the width.
Since bootstrap works in a frame of 12. 4 + 4 leaves 4 short so thats the space thats being filled with justify-content-between.
I also deleted your css since it was not needed.
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<body class="d-flex flex-column min-vh-100">
<!-- -->
<nav class="navbar navbar-light navbar-expand-md bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">
<img src="img/logo.svg" alt="">
</a>
<!-- -->
<div class="navbar-nav d-none d-md-flex">
<a class="nav-link active" aria-current="page" href="#">Home</a>
<a class="nav-link" href="#">A</a>
<a class="nav-link" href="#">B</a>
<a class="nav-link" href="#">C</a>
<a class="nav-link" href="#">D</a>
<a class="nav-link" href="#">E</a>
</div>
<!-- -->
<span>
<a href="https://twitter.com/" rel="nofollow noopener noreferrer"><i
class="fab fa-twitter mx-2 gstwitterblue"></i></a>
<a href="https://www.linkedin.com/"
rel="nofollow noopener noreferrer"><i class="fab fa-linkedin mx-2 gslinkedinblue"></i></a>
</span>
</div>
</nav>
<main class="flex-fill">
<div class="container d-none d-md-flex flex-md-row">
<div class="row justify-content-between">
<div class="col-4">
<div class="card">
<div class="ratio ratio-16x9">
<iframe src="https://www.youtube-nocookie.com/embed/wm48_VrbB4Q?rel=0" allowfullscreen></iframe>
</div>
<div class="card-body">
<p class="card-text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam efficitur orci malesuada sem lacinia, vitae tempor tellus auctor. Sed elementum iaculis quam ac consectetur. Nam ac laoreet est, ut placerat arcu. Ut viverra, quam vitae gravida ornare, arcu felis elementum elit, a pulvinar lacus augue ac nisl. Nunc tincidunt ultricies luctus. Donec et congue ex. Curabitur lacinia scelerisque imperdiet. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aenean ultricies, mauris at ultricies dapibus, urna nisl ullamcorper libero, ac dictum ex neque sed ante. Pellentesque luctus nibh libero, consequat vulputate eros porttitor vitae.</p>
</div>
</div>
</div>
<div class="col-4">
<div class="card gscustomwidth">
<div class="ratio ratio-16x9">
<iframe src="https://www.youtube-nocookie.com/embed/wm48_VrbB4Q?rel=0" allowfullscreen></iframe>
</div>
<div class="card-body">
<p class="card-text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam efficitur orci malesuada sem lacinia, vitae tempor tellus auctor. Sed elementum iaculis quam ac consectetur. Nam ac laoreet est, ut placerat arcu. Ut viverra, quam vitae gravida ornare, arcu felis elementum elit, a pulvinar lacus augue ac nisl. Nunc tincidunt ultricies luctus. Donec et congue ex. Curabitur lacinia scelerisque imperdiet. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aenean ultricies, mauris at ultricies dapibus, urna nisl ullamcorper libero, ac dictum ex neque sed ante. Pellentesque luctus nibh libero, consequat vulputate eros porttitor vitae. </p>
</div>
</div>
</div>
</div>
</div>
</main>
<!-- Standard Footer -->
<footer class="bg-light py-3 d-none d-md-flex">
<div class="container d-flex justify-content-between">
<span class="text-dark fw-lighter">Copyright © 2020 Foobar Ltd. All rights reserved.</span>
<span class="text-dark fw-lighter"><a href="#" class="text-reset text-decoration-none">Legal
Information</a></span>
</div>
</footer>
</body>
The reason what you want doesn't happen is because you're not giving the row div a full width. From your code, add w-100 to the following div:
<div class="row row-cols-1 row-cols-md-2 justify-content-between">

Ellipsis in card header

I am using Bootstrap 4 and I want to create a card header which consists of 3 parts.
Left part displays author.
Middle part displays preview of the content.
Right part displays the date.
I want middle part to cut off with ellipsis when it reaches the end of available space. Middle part should, therefore, span from left to right part with margin ml-5 and mr-5. If content is longer than available width, it should display ellipsis. All 3 parts must be in one line.
Here is my code so far:
<div class="container">
<div class="row">
<div class="col-8">
<div class="card">
<div class="card-header">
<span class="float-left">
John Seed
</span>
<span class="ml-5 mr-5 text-muted" style="text-overflow: ellipsis; white-space: nowrap; overflow: hidden; display: inline-block;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas finibus vitae magna id aliquam. Phasellus luctus ut ligula eu dignissim. Praesent sodales, nisi quis sodales euismod, enim ante suscipit ex, in cursus est metus nec sem. Pellentesque pharetra lobortis sem in tempus. Morbi turpis leo, rhoncus in eleifend id, pellentesque nec metus. Maecenas commodo scelerisque pellentesque. Suspendisse rhoncus at augue at egestas. Ut in erat ut justo tincidunt suscipit ac sit amet urna. Curabitur lacinia diam sit amet velit gravida hendrerit. Duis a orci quis enim iaculis ultrices. Duis finibus lorem et ipsum fringilla, feugiat ullamcorper turpis lacinia. Nunc vulputate in tortor ac lacinia. Pellentesque nec nibh ut est consequat condimentum vel ut velit. Phasellus elementum vel dui vitae lacinia. Nulla et placerat dui, a laoreet lectus.
</span>
<span class="float-right">
10-Mar-2020
</span>
</div>
<div class="card-body">
This is card content.
</div>
</div>
</div>
</div>
</div>
Preview:
If I add, for example, width: 300px to the middle part, it displays ellipsis correctly. However, width is fixed which is not something that I would like.
You can just add a d-flex to the parent container.
Read up on d-flex here
I'd also recommend to remove the float since it isn't needed here. You always want to avoid float whenever possible and use flexbox instead. Float can destroy your layout and has to be cleared.
Edit: To prevent the left and right span to break into a new line you should add the .text-nowrap class from Bootstrap Utility.
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-8">
<div class="card">
<div class="card-header d-flex">
<span class="text-nowrap">
John Seed
</span>
<span class="ml-5 mr-5 text-muted" style="text-overflow: ellipsis; white-space: nowrap; overflow: hidden; display: inline-block;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas finibus vitae magna id aliquam. Phasellus luctus ut ligula eu dignissim. Praesent sodales, nisi quis sodales euismod, enim ante suscipit ex, in cursus est metus nec sem. Pellentesque pharetra lobortis sem in tempus. Morbi turpis leo, rhoncus in eleifend id, pellentesque nec metus. Maecenas commodo scelerisque pellentesque. Suspendisse rhoncus at augue at egestas. Ut in erat ut justo tincidunt suscipit ac sit amet urna. Curabitur lacinia diam sit amet velit gravida hendrerit. Duis a orci quis enim iaculis ultrices. Duis finibus lorem et ipsum fringilla, feugiat ullamcorper turpis lacinia. Nunc vulputate in tortor ac lacinia. Pellentesque nec nibh ut est consequat condimentum vel ut velit. Phasellus elementum vel dui vitae lacinia. Nulla et placerat dui, a laoreet lectus.
</span>
<span class="text-nowrap">
10-Mar-2020
</span>
</div>
<div class="card-body">
This is card content.
</div>
</div>
</div>
</div>

How to do a slight left align in HTML with materializeCSS

This is a two part question. I am trying to emulate this mockup.
I am not quite sure how to do the slight left align of the text as well as adding a circular image in the gray circle area. Currently, my code in this area looks like this:
<div class="index-banner color2">
<div class="section">
<div class="row">
<div class="col s12 center">
<h5 class="header col s12 light">A modern responsive front-end framework based on Material Design</h5>
<p class="left-align light">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam scelerisque id nunc nec volutpat. Etiam pellentesque tristique arcu, non consequat magna fermentum ac. Cras ut ultricies eros. Maecenas eros justo, ullamcorper a sapien id, viverra ultrices eros. Morbi sem neque, posuere et pretium eget, bibendum sollicitudin lacus. Aliquam eleifend sollicitudin diam, eu mattis nisl maximus sed. Nulla imperdiet semper molestie. Morbi massa odio, condimentum sed ipsum ac, gravida ultrices erat. Nullam eget dignissim mauris, non tristique erat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;</p>
</div>
<div class="row center">
<a href="HackPrep.html" class="btn-large waves-effect waves-light green lighten-1" >HackPrep</a>
<span class="divider2"/>
Hackathons
</div>
</div>
</div>
</div>
It looks like this:
How do I make it look remotely close to the mockup? (ignoring the font color and size)
Run below snippet in full page mode.
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.0/css/materialize.min.css" rel="stylesheet"/>
<div class="index-banner color2">
<div class="section">
<div class="row">
<div class="col l8 s12 center">
<h5 class="header col s12 light">A modern responsive front-end framework based on Material Design</h5>
<p class="left-align light ">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam scelerisque id nunc nec volutpat. Etiam pellentesque tristique arcu, non consequat magna fermentum ac. Cras ut ultricies eros. Maecenas eros justo, ullamcorper a s;</p>
<div class="row center">
<a href="HackPrep.html" class="btn-large waves-effect waves-light green lighten-1" >HackPrep</a>
<span class="divider2"/>
Hackathons
</div>
</div>
<div class="col l4 s12 center"><img src="https://dummyimage.com/200x200/000/fff" class="circle">
</div>
</div>
</div>
</div>