Using flexbox to align 3 items in a row - html

I'm trying to align three div's in one row at a 800px break point.
I have two break points in my code and everything works until it hits 800px. At 800px, 'Reviewer 3' ends up on it's own line below 'Reviewer 1 & 2'.
.cards {
display: flex;
flex-direction: column;
align-items: center;
}
.border {
padding: 50px;
font-size: 22px;
}
.center {
position: relative;
left: 25%;
}
#media screen and (min-width: 600px) {
h3 {
color: blue;
}
.cards {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.border {
padding: 50px;
text-align: center;
}
.center {
display: relative;
left: 0;
}
.wrapper {
display: flex;
flex-direction: row;
}
.card-1,
.card-2 {
margin: 15px;
border: 1px solid black;
text-align: center;
width: 50%;
}
.card-3 {
position: relative;
left: 25%;
border: 1px solid black;
margin: 15px;
width: 50%;
text-align: center;
}
#media screen and (min-width: 800px) {
h3 {
color: red;
}
.cards {
display: flex-box;
flex-direction: row;
}
.card-1,
.card-2,
.card-3 {
margin: 30px;
border: 1px solid black;
text-align: center;
width: 30%;
height: 20%;
}
}
<div class="cards">
<div class="wrapper">
<div class="card-1">
<h3>Reviewer 1</h3>
<img class="center" src="https://via.placeholder.com/250" alt="placeholder">
<p class="border">
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam."</p>
</div>
<div class="card-2">
<h3>Reviewer 2</h3>
<img class="center " src="https://via.placeholder.com/250" alt="placeholder">
<p class="border">"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam."</p>
</div>
</div>
<div class="card-3">
<h3>Reviewer 3</h3>
<img class="center" src="https://via.placeholder.com/250" alt="placeholder">
<p class="border" id="b3">"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam."</p>
</div>
</div>

Your problem is an HTML problem. The third box is outside the .wrapper element.
Also, use flex-basis or min-width instead of width. Finally, are you sure you want to use left: 30%?
Update:
Move #media (min-width: 600px) below #media (min-width: 800px) so the 600 one will override when the screen hits the breakpoint
Add some calc() statements to account for borders + margin
Add flex-wrap: wrap to .wrapper (not .cards) because .wrapper is the parent of .card-1, .card-2, and .card-3 (not .cards).
.cards {
display: flex;
flex-direction: column;
align-items: center;
}
.border {
padding: 50px;
font-size: 22px;
}
img {
max-width: 100%;
height: auto;
}
.wrapper {
/* This works for wrapper's children, namely card-1, card-2, card-3 */
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.card-1,
.card-2,
.card-3 {
border: 1px solid black;
text-align: center;
flex-basis: 100%;
}
#media screen and (min-width: 600px) {
h3 {
color: blue;
}
.card-1,
.card-2 {
margin: 15px;
flex-basis: calc(50% - 32px);
}
.card-3 {
position: relative;
margin: 15px;
flex-basis: 100%;
}
}
#media screen and (min-width: 800px) {
h3 {
color: red;
}
.card-1,
.card-2,
.card-3 {
margin: 30px;
flex-basis: calc(33.33% - 62px);
height: 20%;
}
}
<div class="cards">
<div class="wrapper">
<div class="card-1">
<h3>Reviewer 1</h3>
<img class="center" src="https://via.placeholder.com/250" alt="placeholder">
<p class="border">
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam."</p>
</div>
<div class="card-2">
<h3>Reviewer 2</h3>
<img class="center " src="https://via.placeholder.com/250" alt="placeholder">
<p class="border">"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam."</p>
</div>
<div class="card-3">
<h3>Reviewer 3</h3>
<img class="center" src="https://via.placeholder.com/250" alt="placeholder">
<p class="border" id="b3">"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam."</p>
</div>
</div>
</div>

Related

Width ratio for divs/columns in a flex box

I have a responsive template made with a flex box containing a picture div/column and a text div/column. When the width is 50% for both columns, its working fine. But now i want the picture width to be 60% and the text width to be 40%. My problem is when i remove the flex:0 0 auto; width: 50%; in the .container .columns css section and try to give the .columns.image a width of 60% and the .columns.content a width of 40% it creates problems with the media query.
#import url("https://fonts.googleapis.com/css2?family=Assistant&display=swap");
#import url("https://use.typekit.net/yoj6eqg.css");
* {
padding: 0;
margin: 0;
}
body {
overflow-x: hidden;
}
.container {
--bs-gutter-x: 1.5rem;
--bs-gutter-y: 0;
display: flex;
flex-wrap: wrap;
margin: 5% 15% 5% 15%;
}
.container .columns {
flex: 0 0 auto;
width: 50%;
}
.container .columns.image {
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.container .columns.content .content-container {
padding: 40px 50px;
background-color: #e6e6e6;
}
.container .columns.content .content-container h1 {
font-weight: 700;
font-size: 35px;
color: #86b530;
margin-bottom: 20px;
font-family: "p22-underground", sans-serif;
font-weight: 600;
font-style: strong;
}
.container .columns.content .content-container p {
font-weight: 400;
font-size: 16px;
color: #333333;
margin-bottom: 20px;
margin-bottom: 15px;
text-align: justify;
font-family: "Assistant", sans-serif;
}
#media screen and (max-width: 767px) {
.container {
flex-flow: row wrap;
}
.container .columns.image {
display: block;
order: 1;
width: 100%;
height: 250px;
}
.container .columns.content {
display: block;
order: 2;
width: 100%;
}
.container .columns.content .content-container {
padding: 20px 35px;
}
.container .columns.content .content-container h1 {
margin-bottom: 5px;
}
}
<div class="container">
<div style="background-image: url('https://wallpaperset.com/w/full/a/c/7/185665.jpg');" class="columns image">
</div>
<div class="columns content">
<div class="content-container">
<h1>Lorem ipsum</h1>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut
laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud.Lorem ipsum dolor
sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna
aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud.Lorem ipsum dolor sit amet,
consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam
erat volutpat. Ut wisi enim ad minim veniam, quis nostrud.Lorem ipsum dolor sit amet, consectetuer
adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
Ut wisi enim ad minim veniam, quis nostrud.</p>
</div>
</div>
</div>
I tried to apply the different flex ratios and edited the media query, but to no success. I would prefer to keep the flex box instead of changing to a grid. If anyone has a solution, i would be very thankful.
For the equal (50%) column space distribution inside parent .container you used:
.container .columns {
flex: 0 0 auto;
width: 50%;
}
This was sufficient CSS as both columns were equally wide. However, for uneven distribution (60% vs. 40%) you will have to define per column how much parent space it gets:
.container .columns { flex: 0 0 auto }
.container .columns.image { width: 60% }
.container .columns.content { width: 40% }
On smaller devices (<960px) container .columns.content now gets a bit too narrow to my taste, but that's another problem to solve. Maybe another #media with your original 50% distribution...

Full width element: How to make an absolute positioned element to be full width within a grid

I have an article which is within a grid.
The Article body spans 6 columns
I need one of the items within the article body to go full width (beyond the 6 columns container)
The element i am trying make full width is a video / iframe which needs to keep an aspect ratio of 16:9
The video / iframe is absolutely positioned
Here is the code pen so far.
https://codepen.io/miteshsevani/pen/xxEGQdX
.container {
display: block;
margin-left: auto;
margin-right: auto;
max-width: 1536px;
padding-bottom: 24px;
padding-left: 48px;
padding-right: 48px;
width: 100%;
}
.grid {
display: grid;
flex-wrap: nowrap;
grid-gap: 16px;
grid-template-columns: repeat(12, 1fr);
margin-left: 0;
margin-right: 0;
list-style-type: none;
margin: 0 -8px;
padding-left: 0;
}
.article__layout {
grid-column: 2/9;
width: auto;
padding-top: 8px;
padding-left: 0;
padding-right: 0;
}
.video-player.u-align--full-width {
display: grid;
grid-gap: 16px;
grid-template-columns: repeat(7, 1fr);
margin-bottom: 32px;
position: relative;
width: 100vw;
height: auto;
padding-bottom: 56.25%;
padding-bottom: 0;
}
.u-align__wrapper {
padding-bottom: 56.25%;
position: relative;
width: 100vw;
grid-column: 1/7;
align-items: center;
/* display: flex; */
grid-column: 1/-1;
justify-content: center;
vertical-align: middle;
}
.video-player__source.u-align__container {
left: 0;
position: absolute;
top: 0;
width: 100%;
height: 100%;
}
<div class="container">
<div class="grid">
<div class="article__layout">
<div>
<div class="article-body-text">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Praesent tristique magna sit amet purus gravida. Leo integer malesuada nunc vel risus. Mi sit amet mauris commodo quis
imperdiet.</p>
<!-- VIDEO BLOCK START -->
<div>
<div class="alignBodyVideoPlayer">
<div clas="video-player u-align--full-width">
<div class="u-align__wrapper">
<iframe class="video-player__source u-align__container" width="640" height="360" src="https://www.youtube.com/embed/C0DPdy98e4c">
</iframe>
</div>
</div>
</div>
</div>
<!-- VIDEO BLOCK END -->
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Praesent tristique magna sit amet purus gravida. Leo integer malesuada nunc vel risus. Mi sit amet mauris commodo quis
imperdiet.</p>
</div>
</div>
</div>
</div>
</div>
How can I get it to go full width / edge to edge?
I suggest to remove your class grid in your design and add width:100% to the class .u-align__wrapper from what I've observed .u-align__wrapper class contains width:100vw.
Here's the full preview.
.container {
display: block;
margin-left: auto;
margin-right: auto;
max-width: 1536px;
padding-bottom: 24px;
padding-left: 48px;
padding-right: 48px;
width: 100%;
}
.grid {
display: grid;
flex-wrap: nowrap;
grid-gap: 16px;
grid-template-columns: repeat(12,1fr);
margin-left: 0;
margin-right: 0;
list-style-type: none;
margin: 0 -8px;
padding-left: 0;
}
.article__layout {
grid-column: 2/9;
width: auto;
padding-top: 8px;
padding-left: 0;
padding-right: 0;
}
.video-player.u-align--full-width {
display: grid;
grid-gap: 16px;
grid-template-columns: repeat(7,1fr);
margin-bottom: 32px;
position: relative;
width: 100vw;
height: auto;
padding-bottom:56.25%;
padding-bottom: 0;
}
.u-align__wrapper {
padding-bottom: 56.25%;
position: relative;
width: 100%;
grid-column: 1/7;
align-items: center;
/* display: flex; */
grid-column: 1/-1;
justify-content: center;
vertical-align: middle;
}
.video-player__source.u-align__container {
left: 0;
position: absolute;
top: 0;
width: 100%;
height: 100%;
}
<div class="container">
<div class="">
<div class="article__layout">
<div>
<div class="article-body-text">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Praesent tristique magna sit amet purus gravida. Leo integer malesuada nunc vel risus. Mi sit amet mauris commodo quis imperdiet.</p>
<!-- VIDEO BLOCK START -->
<div>
<div class="alignBodyVideoPlayer">
<div clas="video-player u-align--full-width">
<div class="u-align__wrapper">
<iframe class="video-player__source u-align__container" width="640" height="360" src="https://www.youtube.com/embed/C0DPdy98e4c">
</iframe>
</div>
</div>
</div>
</div>
<!-- VIDEO BLOCK END -->
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Praesent tristique magna sit amet purus gravida. Leo integer malesuada nunc vel risus. Mi sit amet mauris commodo quis imperdiet.</p>
</div>
</div>
</div>
</div>
</div>
As much as I'm able to understand your problem, if you remove position: relative; style from your .u-align__wrapper class and add position: relative; to your parent div, i.e .container class, then the video will be of full width and height.

How can i move this button to the upper right side of my div?

I am trying to put my button in the top right corner, i am making a static youtube page for practice. I dont want directly in the corner i would give it some padding around it.
.anotherDescription {
background-color: white;
width: 800px;
height: 150px;
margin-top: 15px;
}
.anotherDescription .profileImg img {
width: 75px;
height: 75px;
border-radius: 50%;
padding: 30px;
float: left;
}
.anotherDescription h4 {
padding-top: 35px;
text-transform: uppercase;
}
.anotherDescription .moreInfo {
padding-top: 5px;
}
.anotherDescription .showMore {
color: gray;
}
.anotherDescription button {
float: right;
}
<div class="anotherDescription">
<div class="profileImg"> <img src="https://d12swbtw719y4s.cloudfront.
net/images/UzogpLEQ/g7F4rwlJRkm
QBBF6j4S/Cartoon.jpeg?w=500"></div>
<h4>loerm ipsum</h4>
<p>Published on March 8, 2019</p>
<p class="moreInfo">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam...</p>
<p class="showMore">Show More</p>
<button>Subscribe</button>
</div>
Did you try to put it upper in the code?
<div class="anotherDescription">
<button>Subscribe</button>
<div class="profileImg"> <img src="https://d12swbtw719y4s.cloudfront.
net/images/UzogpLEQ/g7F4rwlJRkm
QBBF6j4S/Cartoon.jpeg?w=500"></div>
<h4>loerm ipsum</h4>
<p>Published on March 8, 2019</p>
<p class="moreInfo">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam...</p>
<p class="showMore">Show More</p>
</div>
You could absolutely position it to the top right as shown below.
.anotherDescription {
background-color: white;
width: 800px;
height: 150px;
margin-top: 15px;
}
.anotherDescription .profileImg img {
width: 75px;
height: 75px;
border-radius: 50%;
padding: 30px;
float: left;
}
.anotherDescription h4 {
padding-top: 35px;
text-transform: uppercase;
}
.anotherDescription .moreInfo {
padding-top: 5px;
}
.anotherDescription .showMore {
color: gray;
}
.anotherDescription button {
position: absolute;
top: 20px;
right: 20px;
}
<div class="anotherDescription">
<div class="profileImg"> <img src="https://d12swbtw719y4s.cloudfront.
net/images/UzogpLEQ/g7F4rwlJRkm
QBBF6j4S/Cartoon.jpeg?w=500"></div>
<h4>loerm ipsum</h4>
<p>Published on March 8, 2019</p>
<p class="moreInfo">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam...</p>
<p class="showMore">Show More</p>
<button>Subscribe</button>
</div>
</div>
Instead of padding, you would like to give margin to the button; and you need to think that you want the button to be at the top right of div or top right of html document.
If you want the button to be top right of div:
<!DOCTYPE html>
<html>
<head>
<title>try</title>
<style type="text/css">
.anotherDescription {
background-color: white;
width: 800px;
height: 150px;
margin-top: 15px;
}
.anotherDescription .profileImg img {
width: 75px;
height: 75px;
border-radius: 50%;
padding: 30px;
float: left;
}
.anotherDescription h4 {
padding-top: 35px;
text-transform: uppercase;
}
.anotherDescription .moreInfo {
padding-top: 5px;
}
.anotherDescription .showMore {
color: gray;
}
.anotherDescription button {
float: right;
margin: 20px 20px 0px 0px;
}
</style>
</head>
<body>
<div class="anotherDescription">
<button>Subscribe</button>
<div class="profileImg">
<img src="https://d12swbtw719y4s.cloudfront.net/images/UzogpLEQ/g7F4rwlJRkmQBBF6j4S/Cartoon.jpeg?w=500">
</div>
<h4>loerm ipsum</h4>
<p>Published on March 8, 2019</p>
<p class="moreInfo">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam...
</p>
<p class="showMore">Show More</p>
</div>
</body>
</html>
If you want the button to be at the top right of page:
<!DOCTYPE html>
<html>
<head>
<title>try</title>
<style type="text/css">
.anotherDescription {
background-color: white;
width: 800px;
height: 150px;
margin-top: 15px;
}
.anotherDescription .profileImg img {
width: 75px;
height: 75px;
border-radius: 50%;
padding: 30px;
float: left;
}
.anotherDescription h4 {
padding-top: 35px;
text-transform: uppercase;
}
.anotherDescription .moreInfo {
padding-top: 5px;
}
.anotherDescription .showMore {
color: gray;
}
.anotherDescription button {
margin: 20px 20px 0px 0px;
position: absolute;
right: 20px;
}
</style>
</head>
<body>
<div class="anotherDescription">
<button>Subscribe</button>
<div class="profileImg">
<img src="https://d12swbtw719y4s.cloudfront.net/images/UzogpLEQ/g7F4rwlJRkmQBBF6j4S/Cartoon.jpeg?w=500">
</div>
<h4>loerm ipsum</h4>
<p>Published on March 8, 2019</p>
<p class="moreInfo">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam...
</p>
<p class="showMore">Show More</p>
</div>
</body>
</html>
NOTE: I have used Internal Stylesheet in above code. Code starting from tag is CSS part.

Align contents vertically in middle of flexed div

I would like to align the contents of div in the middle of vertical alignment. Table-cell will not function here, due to the fact, that parent is and must be displayed flex. This is used in the new WordPress Gutenberg editor. I do not want to modify the editor itself if possible and achieve this with CSS alone. Below you will find how the code looks currently. Custom HTML also cannot be added without editing editor. Is there a possibility of this be achieved in the current state?
Desired result:
Current code and state:
JSFiddle
HTML:
<div class="wp-block-columns has-2-columns right-33">
<div class="wp-block-column">
<h3>Some title</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </p>
</div>
<div class="wp-block-column">
<figure class="wp-block-image">Here be image</figure>
</div>
</div>
CSS:
h3 {margin: 0 0 20px 0;}
.wp-block-columns {
display: flex;
flex-wrap: no-wrap;
padding: 5px;
border: solid 1px red;
}
.wp-block-column {
flex: 1;
margin-bottom: 1em;
flex-basis: 100%;
min-width: 0;
word-break: break-word;
overflow-wrap: break-word;
flex-grow: 0;
border: solid 1px blue;
}
.right-33 > div:first-child {
flex-basis: 66.6666%;
margin-right: 32px;
}
.right-33 > div:last-child {
flex-basis: 33.3333%;
margin-left: 32px;
}
.wp-block-image {
background: green;
margin: 0 auto;
width: 100%;
height: 200px;
}
You can add this to your wp-block-column column:
.wp-block-column {
display: flex;
flex-direction: column;
justify-content: center;
}
Here's your updated JSFiddle.
This is a great visual guide on Flexbox, it might help you in the future.
Create a column flexbox to .right-33>div:first-child and align to center using justify-content: center - see demo below:
h3 {
margin: 0 0 20px 0;
}
.wp-block-columns {
display: flex;
flex-wrap: no-wrap;
padding: 5px;
border: solid 1px red;
}
.wp-block-column {
flex: 1;
margin-bottom: 1em;
flex-basis: 100%;
min-width: 0;
word-break: break-word;
overflow-wrap: break-word;
flex-grow: 0;
border: solid 1px blue;
}
.right-33>div:first-child {
flex-basis: 66.6666%;
margin-right: 32px;
/*ADDED FLEXBOX*/
display: flex;
flex-direction: column;
justify-content: center;
}
.right-33>div:last-child {
flex-basis: 33.3333%;
margin-left: 32px;
}
.wp-block-image {
background: green;
margin: 0 auto;
width: 100%;
height: 200px;
}
<div class="wp-block-columns has-2-columns right-33">
<div class="wp-block-column">
<h3>Some title</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </p>
</div>
<div class="wp-block-column">
<figure class="wp-block-image">Here be image</figure>
</div>
</div>
The setting to use for vertically centered alignment of flex children is align-items: center;, applied to the flex container. I added it to your code here (at the end of the CSS section):
h3 {
margin: 0 0 20px 0;
}
.wp-block-columns {
display: flex;
flex-wrap: no-wrap;
padding: 5px;
border: solid 1px red;
}
.wp-block-column {
flex: 1;
margin-bottom: 1em;
flex-basis: 100%;
min-width: 0;
word-break: break-word;
overflow-wrap: break-word;
flex-grow: 0;
border: solid 1px blue;
}
.right-33>div:first-child {
flex-basis: 66.6666%;
margin-right: 32px;
}
.right-33>div:last-child {
flex-basis: 33.3333%;
margin-left: 32px;
}
.wp-block-image {
background: green;
margin: 0 auto;
width: 100%;
height: 200px;
}
.wp-block-columns.has-2-columns.right-33 {
align-items: center;
}
<div class="wp-block-columns has-2-columns right-33">
<div class="wp-block-column">
<h3>Some title</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </p>
</div>
<div class="wp-block-column">
<figure class="wp-block-image">Here be image</figure>
</div>
</div>

Equally Marginalize a Left-Aligned Size-Changing Box w/ Image Container in CSS/SASS

Here's the challenge. I have a left-aligned text container (width: 40%;) that changes height with the window. I need my right half of the screen set as an image container (width: 60%) to which the image centers horizontally in the container, and vertically with the center of the text container.
Here is what my current code is doing:
Here is what I would like it to do:
I'm barely savvy in JS, so I'm trying to avoid it pending the need for tweaks. Here is my current code for the section:
.design-portfolio {
position: relative;
.web-img-container {
position: relative;
width: 60%;
margin-left: auto;
.web-img-lg {
img {
max-height: 40em;
}
}
}
.web-img-sm {
#media (min-width:75.063em) {
position: absolute;
visibility: hidden;
}
}
.web-design-box {
#media (min-width:75.063em) {
$font-title: 25px NexaBook;
$font-sub-title: 25px NexaHeavy;
$font-copy-title: 20px NexaHeavy;
$font-copy: 20px NexaBook;
position: relative;
width: 40%;
padding-right: 2em;
.size-fix {
position: relative;
}
.bg-box {
position: absolute;
background-color: $pink;
top: 2em;
bottom: 2em;
left: 0;
right: -2em;
}
.border-box {
position: relative;
border: .3em solid $black;
padding-left: 2em;
padding-right: 2em;
padding-bottom: 2em;
padding-top: 3em;
width: 60%;
margin-left: auto;
.h1 {
font: $font-title;
color: $white;
text-align: right;
}
.h2 {
font: $font-sub-title;
text-align: right;
}
.copy {
font: $font-copy;
color: $white;
text-align: left;
width: 100%;
height: 100%;
.h3 {
font: $font-copy-title;
color: $white;
text-align: left;
}
}
.copy p {
line-height: 1.2;
}
}
}
}
}
<section>
<div class="web-img-container">
<div class="web-img-lg">
<img src="assets/img/website-design.png" alt="web-design">
</div>
</div>
<div class="web-design-box">
<div class="size-fix">
<div class="bg-box"></div>
<div class="border-box">
<div class="h1">
my approach on
</div>
<div class="h2">
website design
</div>
<br>
<div class="copy">
<div class="h3">purpose</div>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
<div class="h3">simplicity</div>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
<div class="h3">mobile first</div>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
</div>
</div>
</div>
</div>
</section>
I don't know how to set it up to run, as it's in SASS rather than regular CSS. :/