I am building a reponsive landing page at the moment that when at full width has 2 boxes that need to match in height, i.e stretch to the tallest. In full width this boxes need to site beside each other, I can get this working with either css grid or flex box as they are on the same row.
When in a mobile size screen the boxes need to wrap beneath each other but still match in height, here is what I have so far.
<div class="welcome-wrapper">
<div class="mt-4 v-card v-sheet theme--light">
<div class="v-card__text text-center">
<p class="headline font-weight-regular text-center my-3">First Action Box</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<button type="button" class="font-weight-bold v-btn v-btn--depressed v-btn--rounded theme--light v-size--x-large success" data-v-step="7"><span class="v-btn__content">Do Action One</span></button>
</div>
</div>
<div class="mt-4 v-card v-sheet theme--light">
<div class="v-card__text text-center">
<p class="headline font-weight-regular text-center my-3">Second Action Box</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam molestie interdum nulla, non rhoncus dolor fringilla vel. Sed eu tellus mollis, auctor sem sed, bibendum purus. Cras eget urna viverra, dapibus urna sed, eleifend massa..</p>
<button type="button" class="font-weight-bold v-btn v-btn--depressed v-btn--rounded theme--light v-size--x-large" style="background-color: rgb(72, 164, 201); border-color: rgb(72, 164, 201);"><span class="v-btn__content">Do action two</span></button>
</div>
</div>
</div>
.welcome-wrapper {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
/* flex-wrap: wrap; */
-webkit-box-align: stretch;
-ms-flex-align: stretch;
align-items: stretch;
flex-direction: row;
justify-content: space-between;
}
.welcome-wrapper .v-card {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-flex: 1;
-ms-flex: 1 1 100%;
flex: 1 1 100%;
flex-basis: 100%;
}
.welcome-wrapper .v-card .v-card__text {
height: 100%;
width: 100%;
}
Anyone any advice on how to match to elements height when they are not actually in a row?
Ignoring the bootstrap classes, here it goes.
.welcome-wrapper {
display: flex;
flex-direction: column;
}
#media(min-width:768px) {
.welcome-wrapper {
display: flex;
flex-direction: row;
justify-content: space-between;
}
}
.welcome-wrapper .v-card {
background-color: #333;
color: #f0f0f0;
border: 0.05rem solid #eee;
flex: 1 1 0;
padding: 2rem;
}
<div class="welcome-wrapper">
<div class="v-card">
<div>
<p>First Action Box</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<button>
Do Action One
</button>
</div>
</div>
<div class="v-card">
<div>
<p>Second Action Box</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam molestie interdum nulla, non rhoncus dolor fringilla vel. Sed eu tellus mollis, auctor sem sed, bibendum purus. Cras eget urna viverra, dapibus urna sed, eleifend massa..</p>
<button>
Do Action One
</button>
</div>
</div>
</div>
Related
I'm struggling to align a group of boxes in the center of my webpage when displayed on a computer screen. I'm floating the boxes left but then it's assymetrical with more space on the right. It's currently looking like this:
! https://imgur.com/a/wq0yv6S
I tried a few different alignment properties to the "boxes" and "box" classes but they didn't accomplish anything.
HTML of the section + first box and CSS:
#boxes {
margin-top: 20px;
}
#boxes .box {
float: left;
width: 20%;
padding: 10px;
text-align: center;
align-self: center;
justify-content: space-around;
}
#boxes .box img {
width: 200px;
}
<section id="boxes">
<div class="container">
<div class="box">
<img src="./img/foto0.jpg">
<h2>Pessoa Fisica</h2>
<p>Cuidamos da sua declaracao de imposto de renda</p>
</div>
I'd like to have those boxes positioned symmetrically.
You can use display: grid;
.grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-gap: 1em;
}
.grid-item {
background: #F7F7F7;
padding: 1em;
text-align: center;
}
<div class="grid">
<div class="grid-item">1</div>
<div class="grid-item">2</div>
<div class="grid-item">3</div>
<div class="grid-item">4</div>
</div>
You could use flexbox,
it's very easy to start with,
you need to implement this CSS code to the parent container which you need its children to be aligned in someway
.container{
display: flex;
justify-content: center;
align-items: center;
}
<section id="boxes">
<div class="container">
<div class="box">
<img src="./img/foto0.jpg">
<h2>Pessoa Fisica</h2>
<p>Cuidamos da sua declaracao de imposto de renda</p>
</div>
What you're trying to achieve is not too hard with flexbox. See the following demo for an example. If you have any questions please ask :).
Note: The .site div is not needed but added for reference.
.container {
width: 100%;
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
max-width: 960px;
}
.row {
display: flex;
align-items: center;
flex-wrap: wrap;
margin-right: -15px;
margin-left: -15px;
}
.box {
position: relative;
flex-basis: 0;
flex-grow: 1;
max-width: 100%;
padding-right: 15px;
padding-left: 15px;
}
.site {
border: 1px solid red;
}
img {
max-width: 100%;
height: auto;
}
<div class="site">
<div class="container">
<div class="row">
<div class="box">
<img src="https://dummyimage.com/300x200/f9f9f9/aaa" alt="">
<h2>Title #1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi dui purus, porta sit amet elit ut, pretium dapibus ante. Suspendisse non pharetra odio. Mauris ac placerat libero.</p>
</div>
<div class="box">
<img src="https://dummyimage.com/300x200/f9f9f9/aaa" alt="">
<h2>Title #1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi dui purus, porta sit amet elit ut, pretium dapibus ante. Suspendisse non pharetra odio. Mauris ac placerat libero.</p>
</div>
<div class="box">
<img src="https://dummyimage.com/300x200/f9f9f9/aaa" alt="">
<h2>Title #1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi dui purus, porta sit amet elit ut, pretium dapibus ante. Suspendisse non pharetra odio. Mauris ac placerat libero.</p>
</div>
<div class="box">
<img src="https://dummyimage.com/300x200/f9f9f9/aaa" alt="">
<h2>Title #1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi dui purus, porta sit amet elit ut, pretium dapibus ante. Suspendisse non pharetra odio. Mauris ac placerat libero.</p>
</div>
</div>
</div>
</div>
I am making cards using flexbox(https://jsfiddle.net/vs37qo0r/):
/* Only included flex related styles*/
.container {
display: flex;
flex-direction: row;
/*default*/
align-items: stretch;
/*default*/
justify-content: space-around;
}
.card {
flex-basis: 20%;
}
<div class="container">
<div class="card">
<h3>Feature 1</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam finibus arcu est, id mollis ex tincidunt blandit. Morbi dictum dignissim turpis. Ut lacus leo, sagittis at ullamcorper eu, auctor a arcu. Sed non mi sed turpis rhoncus faucibus eu viverra.
</p>
<button type="button">Go Somewhere</button>
</div>
<!-- two more cards of same format-->
</div>
Each <h3> and <p> line up with each other. But, not every <p> is the same size, which then throws off where the <button> is layed out. How can I tell all of the <button>s to line up with each other regardless of the size of the <p> above it?
Set .card to display: flex
Enclose h3, p in a wrapper with flex: 1
Set the button to be at flex-end
jfFiddle
body{
background-color: white;
margin-top: 100px;
padding: 0;
}
.container{
display:flex;
flex-direction: row; /*default*/
align-items: stretch; /*default*/
justify-content: space-around;
}
.card{
border: 1px solid grey;
border-radius: 3px;
background-color: white;
flex-basis: 20%;
text-align: center;
padding: 30px;
font-family: 'Roboto', sans-serif;
display: flex;
flex-direction: column;
}
.card__content {
flex: 1;
}
.button {
align-self: flex-end;
}
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="card">
<div class="card__content">
<h3>Feature 1</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam finibus arcu est, id mollis ex tincidunt blandit. Morbi dictum dignissim turpis. Ut lacus leo, sagittis at ullamcorper eu, auctor a arcu. Sed non mi sed turpis rhoncus faucibus eu viverra.
</p>
</div>
<button type="button">Go Somewhere</button>
</div>
<div class="card">
<div class="card__content">
<h3>Feature 2</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam finibus arcu est, id mollis ex tincidunt blandit. Morbi dictum
</p>
</div>
<button type="button">Go Somewhere</button>
</div>
<div class="card">
<div class="card__content">
<h3>Feature 3</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam finibus arcu est, id mollis ex tincidunt blandit. Morbi dictum dignissim turpis. Ut lacus leo, sagittis at ullamcorper eu, auctor a arcu. Sed non mi sed turpis rhoncus faucibus eu viverra.
</p>
</div>
<button type="button">Go Somewhere</button>
</div>
</div>
</body>
jsFiddle
There is no need for a wrapper or more than 3 additional properties. Set .card to flex:
.card {
display:flex;
flex-direction: column;
....
}
Set .card p to flex: 1
.card p {
flex: 1;
}
Try making the .card elements flex-parents themselves, then play with the justify-content property.
.card{
…
display: flex;
flex-direction: column;
justify-content: space-between;
}
body {
background-color: white;
margin-top: 100px;
padding: 0;
}
.container {
display: flex;
flex-direction: row;
/*default*/
align-items: stretch;
/*default*/
justify-content: space-around;
}
.card {
border: 1px solid grey;
border-radius: 3px;
background-color: white;
flex-basis: 20%;
text-align: center;
padding: 30px;
font-family: 'Roboto', sans-serif;
display: flex;
flex-direction: column;
justify-content: space-between;
}
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="card">
<h3>Feature 1</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam finibus arcu est, id mollis ex tincidunt blandit. Morbi dictum dignissim turpis. Ut lacus leo, sagittis at ullamcorper eu, auctor a arcu. Sed non mi sed turpis rhoncus faucibus eu viverra.
</p>
<button type="button">Go Somewhere</button>
</div>
<div class="card">
<h3>Feature 2</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam finibus arcu est, id mollis ex tincidunt blandit. Morbi dictum
</p>
<button type="button">Go Somewhere</button>
</div>
<div class="card">
<h3>Feature 3</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam finibus arcu est, id mollis ex tincidunt blandit. Morbi dictum dignissim turpis. Ut lacus leo, sagittis at ullamcorper eu, auctor a arcu. Sed non mi sed turpis rhoncus faucibus eu viverra.
</p>
<button type="button">Go Somewhere</button>
</div>
</div>
</body>
I'm working with you jsfiddle version:
there I added these extra code, and you never have to touch your HTML for it!
.card{
...
display: flex;
flex-direction: column;
align-items: center;
}
button {
margin-top: auto !important;
}
and it's working fine!
body {
background-color: white;
margin-top: 100px;
padding: 0;
}
.container {
display: flex;
flex-direction: row;
/* default */
align-items: stretch;
/* default */
justify-content: space-around;
}
.card {
border: 1px solid grey;
border-radius: 3px;
background-color: white;
flex-basis: 20%;
text-align: center;
padding: 30px;
font-family: 'Roboto', sans-serif;
display: flex;
flex-direction: column;
align-items: center;
}
button {
margin-top: auto;
}
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="card">
<h3>Feature 1</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam finibus arcu est, id mollis ex tincidunt blandit. Morbi dictum dignissim turpis. Ut lacus leo, sagittis at ullamcorper eu, auctor a arcu. Sed non mi sed turpis rhoncus faucibus eu viverra.
</p>
<button type="button">Go Somewhere</button>
</div>
<div class="card">
<h3>Feature 2</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam finibus arcu est, id mollis ex tincidunt blandit. Morbi dictum
</p>
<button type="button">Go Somewhere</button>
</div>
<div class="card">
<h3>Feature 3</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam finibus arcu est, id mollis ex tincidunt blandit. Morbi dictum dignissim turpis. Ut lacus leo, sagittis at ullamcorper eu, auctor a arcu. Sed non mi sed turpis rhoncus faucibus eu viverra.
</p>
<button type="button">Go Somewhere</button>
</div>
</div>
</body>
You need to add display: flex, flex-dicrection: column and justify-content: space-between.
Your new css .card class looks like:
.card{
flex-basis: 20%;
display: flex;
flex-direction: column;
justify-content: space-between;
}
I hope this will work for you!
I am trying to make a box with a few sections of text. Each section will have a floating label on the left of it. However I have encountered a problem where the end of the text overflows onto the next section.
Is there a way to prevent this?
.punktBox {
width: 550px;
margin-bottom: 15px;
font-size: 1.1em;
display: flex;
flex-wrap: wrap;
}
.punktSection, .punktSectionHalf {
font-size: 1em;
padding: 2px 10px;
min-height: 24px;
display: inline-block;
width: 100%;
flex: 0 1 auto;
}
.punktSecLabel {
float: left;
height: 100%;
min-width: 100px;
font-weight: bold;
}
<div class="punktBox">
<div class="punktSection">
<div class="punktSecLabel">Desc: </div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris venenatis, felis id euismod lacinia, ligula sapien consequat augue, sed volutpat felis ipsum ut ipsum. In hac habitasse platea dictumst. Nunc porttitor nisl a suscipit suscipit.<i> (3 min lub mniej) </i>
</div>
<div class="punktSectionHalf">
<div class="punktSecLabel">Person: </div>John Doe
</div>
<div class="punktSection">
<div class="punktSecLabel">Lorem: </div>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
</div>
I suggest just use inline-flex and put your content inside a <p> or <div> element otherwise it will break.
.punktBox {
width: 550px;
margin-bottom: 15px;
font-size: 1.1em;
display: flex;
flex-wrap: wrap;
}
.punktSection, .punktSectionHalf {
font-size: 1em;
padding: 2px 10px;
min-height: 24px;
display: inline-flex;
width: 100%;
flex: 0 1 auto;
}
.punktSecLabel {
height: 100%;
min-width: 100px;
font-weight: bold;
}
<div class="punktBox">
<div class="punktSection">
<div class="punktSecLabel">Desc: </div><div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris venenatis, felis id euismod lacinia, ligula sapien consequat augue, sed volutpat felis ipsum ut ipsum. In hac habitasse platea dictumst. Nunc porttitor nisl a suscipit suscipit.<i> (3 min lub mniej) </i></div>
</div>
<div class="punktSectionHalf">
<div class="punktSecLabel">Person: </div><div>John Doe</div>
</div>
<div class="punktSection">
<div class="punktSecLabel">Lorem: </div><div>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>
</div>
</div>
Instead of display: inline-block on your .punktSection and .punktSectionHalf, you're looking for display: inline-flex:
.punktBox {
width: 550px;
margin-bottom: 15px;
font-size: 1.1em;
display: flex;
flex-wrap: wrap;
}
.punktSection, .punktSectionHalf {
font-size: 1em;
padding: 2px 10px;
min-height: 24px;
display: inline-flex;
width: 100%;
flex: 0 1 auto;
}
.punktSecLabel {
float: left;
height: 100%;
min-width: 100px;
font-weight: bold;
}
<div class="punktBox">
<div class="punktSection">
<div class="punktSecLabel">Desc: </div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris venenatis, felis id euismod lacinia, ligula sapien consequat augue, sed volutpat felis ipsum ut ipsum. In hac habitasse platea dictumst. Nunc porttitor nisl a suscipit suscipit.<i> (3 min lub mniej) </i>
</div>
<div class="punktSectionHalf">
<div class="punktSecLabel">Person: </div>John Doe
</div>
<div class="punktSection">
<div class="punktSecLabel">Lorem: </div>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
</div>
Your problem is that you had a float:left on your punktSecLabel.
Just remote it, and add a display:flex; on your punktSection. Your content must also be wrapped in a bigger div.
Hope it helps !
.punktBox {
width: 550px;
margin-bottom: 15px;
font-size: 1.1em;
display: flex;
flex-wrap: wrap;
}
.punktSection, .punktSectionHalf {
font-size: 1em;
padding: 2px 10px;
min-height: 24px;
display: inline-block;
width: 100%;
flex: 0 1 auto;
display:flex;
}
.punktSecLabel {
height: 100%;
min-width: 100px;
font-weight: bold;
}
<div class="punktBox">
<div class="punktSection">
<div class="punktSecLabel">Desc: </div><div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris venenatis, felis id euismod lacinia, ligula sapien consequat augue, sed volutpat felis ipsum ut ipsum. In hac habitasse platea dictumst. Nunc porttitor nisl a suscipit suscipit.<i> (3 min lub mniej) </i></div>
</div>
<div class="punktSectionHalf">
<div class="punktSecLabel">Person: </div>John Doe
</div>
<div class="punktSection">
<div class="punktSecLabel">Lorem: </div>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
</div>
In the below code, I want all the three boxes to have same height and also the links in the three boxes should be in same line as shown in the screenshot below. I have used flexbox for doing this. Please help.
.wrapper {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: stretch;
padding-top: 35px;
padding-bottom: 35px;
background-color: pink;
}
.wrapper div:not(:last-child) {
border-right: 1px solid #fdfdfd;
}
.wrapper div {
flex-basis: 33%;
text-align: center;
padding: 10px 4%;
}
<div class="wrapper">
<div>
<span>Heading1</span>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent erat ex, scelerisque sed pellentesque ut, egestas eget velit. Vestibulum sodales finibus faucibus. </p>
Link1
</div>
<div>
<span>Heading2</span>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent erat ex, sceleriit. Vestibulum sodales finibus fausque.sit amet, consectetur adipiscin </p>
Link2
</div>
<div>
<span>Heading3</span>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing . esent erat ex, sceler erat ex, sciit. Vestileriibulum sodales finibus fausque sed pellentesque ut, egestas eget velit. Vestibulum sodales finibus faucibus. </p>
Link3
</div>
</div>
Remove align-items: flex-start; from the wrapper, give the div display: flex; flex-direction: column;, and set margin-top: auto on the links
.wrapper {
display: flex;
flex-direction: row;
justify-content: space-between;
padding-top: 35px;
padding-bottom: 35px;
background-color: pink;
}
.wrapper div:not(:last-child) {
border-right: 1px solid #fdfdfd;
}
.wrapper div {
flex-basis: 33%;
text-align: center;
padding: 10px 4%;
display: flex; /* added property */
flex-direction: column; /* added property */
}
.wrapper div a { /* added rule */
margin-top: auto;
}
<div class="wrapper">
<div>
<span>Heading1</span>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent erat ex, scelerisque sed pellentesque ut, egestas eget velit. Vestibulum sodales finibus faucibus. </p>
Link1
</div>
<div>
<span>Heading2</span>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent erat ex, sceleriit. Vestibulum sodales finibus fausque.sit amet, consectetur adipiscin </p>
Link2
</div>
<div>
<span>Heading3</span>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing . esent erat ex, sceler erat ex, sciit. Vestileriibulum sodales finibus fausque sed pellentesque ut, egestas eget velit. Vestibulum sodales finibus faucibus. </p>
Link3
</div>
</div>
.wrapper {
display: flex;
flex-direction: row;
justify-content: stretch;
padding-top: 35px;
padding-bottom: 35px;
background-color: pink;
}
.wrapper div:not(:last-child) {
border-right: 1px solid #fdfdfd;
}
.wrapper div {
display: flex;
flex-basis: 33%;
flex-direction: column;
justify-content: space-between;
text-align: center;
padding: 10px 4%;
}
.wrapper div a {
flex-grow: 1;
display: flex;
justify-content: center;
align-items: flex-end;
}
<div class="wrapper">
<div>
<span>Heading1</span>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent erat ex, scelerisque sed pellentesque ut, egestas eget velit. Vestibulum sodales finibus faucibus. </p>
Link1
</div>
<div>
<span>Heading2</span>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent erat ex, sceleriit. Vestibulum sodales finibus fausque.sit amet, consectetur adipiscin </p>
Link2
</div>
<div>
<span>Heading3</span>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing . esent erat ex, sceler erat ex, sciit. Vestileriibulum sodales finibus fausque sed pellentesque ut, egestas eget velit. Vestibulum sodales finibus faucibus. </p>
Link3
</div>
</div>
I've got div containers that are using flex. I have a bold senescence inside my flex child containers.
example
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc at lectus vitae libero pulvinar fringilla. Nullam vel vestibulum orci.
However, when I create my flex container it's not making the bold text inline. It's creating a block between the regular text and the bold text.
example
Lorem ipsum dolor
sit amet, consectetur adipiscing elit. Nunc at lectus vitae libero
pulvinar fringilla. Nullam vel vestibulum orci.
I've set my flex container as follows:
.flexparent { display: flex; flex-direction: row; justifty-content: center; flex-wrap: wrap-reverse }
.flexchild1 { display: inline-flex; flex-direction: column; flex-wrap: nowrap; justify-contetn: center; width: 65%; margin-right: 4%;}
.flexchild2 { display: inline-flex; flex-direction: column; flex-wrap: nowrap; justify-contetn: center; width: 35%;}
My ideal solution is something like this where .flexchild1 is green and .flexchild2 is yellow.
If you're going to use a flex container, keep in mind that all child elements will become flex items and stack vertically or horizontally, depending on flex-direction.
So, if we consider this code:
<div class="flex-container"><b>Lorem ipsum dolor sit amet</b> consectetur adipiscing elit. <span>Nunc at lectus vitae libero</span> pulvinar fringilla. <i>Nullam vel vestibulum orci.</i></div>
Although, the <b>, <span> and <i> elements are inline-level in a block formatting content...
.flex-container {
display: block;
flex-direction: row;
background-color: lightgreen;
}
span { color: red; }
<div class="flex-container"><b>Lorem ipsum dolor sit amet</b> consectetur adipiscing elit. <span>Nunc at lectus vitae libero</span> pulvinar fringilla. <i>Nullam vel vestibulum orci.</i></div>
ALL child elements are blockified in a flex formatting context...
.flex-container1 {
display: flex;
flex-direction: row;
background-color: lightgreen;
}
.flex-container2 {
display: flex;
flex-direction: column;
background-color: lightgreen;
}
span { color: red; }
<div class="flex-container1"><b>Lorem ipsum dolor sit amet</b> consectetur adipiscing elit. <span>Nunc at lectus vitae libero</span> pulvinar fringilla. <i>Nullam vel vestibulum orci.</i></div>
<hr>
<div class="flex-container2"><b>Lorem ipsum dolor sit amet</b> consectetur adipiscing elit. <span>Nunc at lectus vitae libero</span> pulvinar fringilla. <i>Nullam vel vestibulum orci.</i></div>
What you may want to do is wrap your text in its own block-level container within the flex container.
.flex-container1 {
display: flex;
flex-direction: row;
background-color: lightgreen;
}
.flex-container2 {
display: flex;
flex-direction: column;
background-color: lightgreen;
}
span {
color: red;
}
<div class="flex-container1">
<div>
<b>Lorem ipsum dolor sit amet</b> consectetur adipiscing elit. <span>Nunc at lectus vitae libero</span> pulvinar fringilla. <i>Nullam vel vestibulum orci.</i>
</div>
</div>
<hr>
<div class="flex-container2">
<div>
<b>Lorem ipsum dolor sit amet</b> consectetur adipiscing elit. <span>Nunc at lectus vitae libero</span> pulvinar fringilla. <i>Nullam vel vestibulum orci.</i>
</div>
</div>