I'm trying to add a x-axis scrollable slider, but cant seems to figure it out.
Here, I'm trying to do a horizontal card scroll. If I add padding to the card Wrapper it extends itself out of the body. which I don't want to happen. Therefore I removed the padding and added overflow-x: scroll . I thought it will solve the issue and I will be able to scroll left/right.
Please tell me how to add the scroll without going out of the body.
Thanks in advance.
.services {
display: flex;
flex-direction: column;
width: 100%;
overflow-x: visible;
height: fit-content;
align-items: center;
justify-content: space-between;
padding: 30px 0;
}
.cardWrapper {
display: flex;
background: red;
overflow-x: scroll;
flex-direction: row;
justify-content: space-around;
}
.cardContainer {
width: 500px;
height: 500px;
background: blue;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-around;
}
.cardContainer .cardsImage {
width: 60%;
}
.cardContainer .cardsImage img {
width: 100%;
}
.cardContainer .cardContents {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
}
<div class="services">
<h1>Our Services</h1>
<div class="cardWrapper">
<div class="cardContainer">
<div class="cardsImage">
<img src="https://via.placeholder.com/300" alt="Qa Services">
</div>
<div class="cardContents">
<h2>Qa Services</h2>
<p>Our Qa engineers don't just test,they make your software application successful ensuring quality delivery with expert manual and automated testing services.</p>
</div>
</div>
<div class="cardContainer">
<div class="cardsImage">
<img src="https://via.placeholder.com/300" alt="Qa Services">
</div>
<div class="cardContents">
<h2>Qa Services</h2>
<p>Our Qa engineers don't just test,they make your software application successful ensuring quality delivery with expert manual and automated testing services.</p>
</div>
</div>
<div class="cardContainer">
<div class="cardsImage">
<img src="https://via.placeholder.com/300" alt="Qa Services">
</div>
<div class="cardContents">
<h2>Qa Services</h2>
<p>Our Qa engineers don't just test,they make your software application successful ensuring quality delivery with expert manual and automated testing services.</p>
</div>
</div>
</div>
</div>
You need to have a simple wrapper that acts as a boundary for your scrollbar. Then inside you need the wrapper for your flex contents.
In addition, simple using a width on elements within a flex context is not enough. You need to provide flex as well
.services {
padding: 30px 0;
}
.cardWrapperOuter {
overflow-x: scroll;
}
.cardWrapper {
display: flex;
background: red;
}
.cardContainer {
flex: 0 0 500px;
width: 500px;
height: 500px;
background: blue;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-around;
}
.cardContainer .cardsImage {
width: 60%;
}
.cardContainer .cardsImage img {
width: 100%;
}
.cardContainer .cardContents {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
}
<div class="services">
<h1>Our Services</h1>
<div class="cardWrapperOuter">
<div class="cardWrapper">
<div class="cardContainer">
<div class="cardsImage">
<img src="./assets/images/QaServices.svg" alt="Qa Services">
</div>
<div class="cardContents">
<h2>Qa Services</h2>
<p>Our Qa engineers don't just test,they make your software application successful ensuring quality delivery with expert manual and automated testing services.</p>
</div>
</div>
<div class="cardContainer">
<div class="cardsImage">
<img src="./assets/images/QaServices.svg" alt="Qa Services">
</div>
<div class="cardContents">
<h2>Qa Services</h2>
<p>Our Qa engineers don't just test,they make your software application successful ensuring quality delivery with expert manual and automated testing services.</p>
</div>
</div>
<div class="cardContainer">
<div class="cardsImage">
<img src="./assets/images/QaServices.svg" alt="Qa Services">
</div>
<div class="cardContents">
<h2>Qa Services</h2>
<p>Our Qa engineers don't just test,they make your software application successful ensuring quality delivery with expert manual and automated testing services.</p>
</div>
</div>
</div>
</div>
</div>
Related
I'm new to CSS and HTML. I made 3 boxes next to each other and I want to have 2 more rows of 3 boxes per row. I can't seem to understand how to separate the rows. They always end up on the same row, distorted and I've been trying all morning to fix it. I will appreciate your help, thank you!
.container {
display: flex;
justify-content: space-between;
}
.box {
width: 400px;
height: 240px;
background-color: #ccc;
margin: 10px;
transition: all 0.3s ease-in-out;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
overflow: hidden;
text-align: justify;
position: relative;
}
.box:hover {
transform: scale(1.1);
}
.box .content {
font-size: 10px;
padding: 20px;
color: #fff;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
}
.box .title {
font-size: 14px;
font-weight: bold;
margin-bottom: 10px;
position: justify;
top: 50%;
left: 50%;
}
.box:nth-child(1) {
background-color: #fec10d;
}
.box:nth-child(2) {
background-color: #0077c0;
}
.box:nth-child(3) {
background-color: #b2d234;
}
.box img {
position: relative;
top: 1%;
left: 50%;
transform: translateX(-175%);
height: 80px;
width: 80px;
object-fit: contain;
margin-bottom: 5px;
padding-bottom: 5px;
margin: auto;
display: block;
}
<div class="container">
<div class="box">
<div class="content">
<img src="https://printeconline.sharepoint.com/:i:/r/sites/Marketing/Group%20Marketing%20Folder/Brand/Brand%20Materials/Values/Icons/Icons/Printec_Values_Icons_White_500x500px/Printec_Care_Icon_White_500x500px.png?csf=1&web=1&e=paSbKD" alt="Care">
<div class="title">TEAMWORK</div>
<div>Actively seeks opportunities to collaborate with and support others. Builds relationships across the organization, shares knowledge and experience, involve others and communicates effectively.</div>
</div>
</div>
<div class="box">
<div class="content">
<img src="https://printeconline.sharepoint.com/:i:/r/sites/Marketing/Group%20Marketing%20Folder/Brand/Brand%20Materials/Values/Icons/Icons/Printec_Values_Icons_White_500x500px/Printec_Care_Icon_White_500x500px.png?csf=1&web=1&e=paSbKD" alt="Care">
<div class="title">BUILDS TRUST</div>
<div>Gains the trust of others through honesty and authenticity. Shows consistency between his/her words and actions, upholds professional codes of conduct, acts in accordance with the company’s policies, delivers on promises, and takes personal responsibility
for decisions, actions, and mistakes.</div>
</div>
</div>
<div class="box">
<div class="content">
<img src="https://printeconline.sharepoint.com/:i:/r/sites/Marketing/Group%20Marketing%20Folder/Brand/Brand%20Materials/Values/Icons/Icons/Printec_Values_Icons_White_500x500px/Printec_Care_Icon_White_500x500px.png?csf=1&web=1&e=paSbKD" alt="Care">
<div class="title">CARE FOR OTHERS AND INCLUSION</div>
<div>Actively seeks opportunities to collaborate with and support others. Builds relationships across the organization, shares knowledge and experience, involve others and communicates effectively.</div>
</div>
</div>
</div>
Please use the below code.
.container {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
gap: 20px;
}
.box {
background-color: #ccc;
transition: all 0.3s ease-in-out;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
overflow: hidden;
text-align: justify;
flex-basis: calc(32% - 6.67px); /* calculate flex-basis to account for gap */
margin-bottom: 20px;
}
.box:hover {
transform: scale(1.1);
}
.box .content {
font-size: 10px;
padding: 20px;
color: #fff;
display: flex;
flex-direction: column;
align-items: center;
height: 100%;
}
.box .title {
font-size: 14px;
font-weight: bold;
margin-bottom: 10px;
text-align: center;
}
.box:nth-child(1) {
background-color: #fec10d;
}
.box:nth-child(2) {
background-color: #0077c0;
}
.box:nth-child(3) {
background-color: #b2d234;
}
.box img {
position: relative;
height: 80px;
width: 80px;
object-fit: contain;
margin-bottom: 5px;
padding-bottom: 5px;
}
below code:
<div class="container">
<div class="box">
<div class="content">
<img src="https://img.freepik.com/free-vector/team-work-linear-design_1284-35744.jpg?w=1480&t=st=1676633574~exp=1676634174~hmac=17f549203c31724f00ab9d71befd333b53daa983a4f6974cbdb1ec4dbc3c3ad5" alt="Care">
<div class="title">TEAMWORK</div>
<div>Actively seeks opportunities to collaborate with and support others. Builds relationships across the organization, shares knowledge and experience, involve others and communicates effectively.</div>
</div>
</div>
<div class="box">
<div class="content">
<img src="https://img.freepik.com/free-vector/team-work-linear-design_1284-35744.jpg?w=1480&t=st=1676633574~exp=1676634174~hmac=17f549203c31724f00ab9d71befd333b53daa983a4f6974cbdb1ec4dbc3c3ad5" alt="Care">
<div class="title">BUILDS TRUST</div>
<div>Gains the trust of others through honesty and authenticity. Shows consistency between his/her words and actions, upholds professional codes of conduct, acts in accordance with the company’s policies, delivers on promises, and takes personal responsibility
for decisions, actions, and mistakes.</div>
</div>
</div>
<div class="box">
<div class="content">
<img src="https://img.freepik.com/free-vector/team-work-linear-design_1284-35744.jpg?w=1480&t=st=1676633574~exp=1676634174~hmac=17f549203c31724f00ab9d71befd333b53daa983a4f6974cbdb1ec4dbc3c3ad5" alt="Care">
<div class="title">CARE FOR OTHERS AND INCLUSION</div>
<div>Actively seeks opportunities to collaborate with and support others. Builds relationships across the organization, shares knowledge and experience, involve others and communicates effectively.</div>
</div>
</div>
<div class="box">
<div class="content">
<img src="https://img.freepik.com/free-vector/team-work-linear-design_1284-35744.jpg?w=1480&t=st=1676633574~exp=1676634174~hmac=17f549203c31724f00ab9d71befd333b53daa983a4f6974cbdb1ec4dbc3c3ad5" alt="Care">
<div class="title">TEAMWORK</div>
<div>Actively seeks opportunities to collaborate with and support others. Builds relationships across the organization, shares knowledge and experience, involve others and communicates effectively.</div>
</div>
</div>
<div class="box">
<div class="content">
<img src="https://img.freepik.com/free-vector/team-work-linear-design_1284-35744.jpg?w=1480&t=st=1676633574~exp=1676634174~hmac=17f549203c31724f00ab9d71befd333b53daa983a4f6974cbdb1ec4dbc3c3ad5" alt="Care">
<div class="title">TEAMWORK</div>
<div>Actively seeks opportunities to collaborate with and support others. Builds relationships across the organization, shares knowledge and experience, involve others and communicates effectively.</div>
</div>
</div>
</div>
Apply these changes to resolve this issue :
.container {
display: flex;
justify-content: center;
}
/* add this style */
.boxes {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;
}
<div class="container">
<div class="boxes">
<div class="box">
<div class="content">
<img
src="https://printeconline.sharepoint.com/:i:/r/sites/Marketing/Group%20Marketing%20Folder/Brand/Brand%20Materials/Values/Icons/Icons/Printec_Values_Icons_White_500x500px/Printec_Care_Icon_White_500x500px.png?csf=1&web=1&e=paSbKD"
alt="Care"
/>
<div class="title">TEAMWORK</div>
<div>
Actively seeks opportunities to collaborate with and support
others. Builds relationships across the organization, shares
knowledge and experience, involve others and communicates
effectively.
</div>
</div>
</div>
<div class="box">
<div class="content">
<img
src="https://printeconline.sharepoint.com/:i:/r/sites/Marketing/Group%20Marketing%20Folder/Brand/Brand%20Materials/Values/Icons/Icons/Printec_Values_Icons_White_500x500px/Printec_Care_Icon_White_500x500px.png?csf=1&web=1&e=paSbKD"
alt="Care"
/>
<div class="title">BUILDS TRUST</div>
<div>
Gains the trust of others through honesty and authenticity. Shows
consistency between his/her words and actions, upholds
professional codes of conduct, acts in accordance with the
company’s policies, delivers on promises, and takes personal
responsibility for decisions, actions, and mistakes.
</div>
</div>
</div>
<div class="box">
<div class="content">
<img
src="https://printeconline.sharepoint.com/:i:/r/sites/Marketing/Group%20Marketing%20Folder/Brand/Brand%20Materials/Values/Icons/Icons/Printec_Values_Icons_White_500x500px/Printec_Care_Icon_White_500x500px.png?csf=1&web=1&e=paSbKD"
alt="Care"
/>
<div class="title">CARE FOR OTHERS AND INCLUSION</div>
<div>
Actively seeks opportunities to collaborate with and support
others. Builds relationships across the organization, shares
knowledge and experience, involve others and communicates
effectively.
</div>
</div>
</div>
<div class="box">
<div class="content">
<img
src="https://printeconline.sharepoint.com/:i:/r/sites/Marketing/Group%20Marketing%20Folder/Brand/Brand%20Materials/Values/Icons/Icons/Printec_Values_Icons_White_500x500px/Printec_Care_Icon_White_500x500px.png?csf=1&web=1&e=paSbKD"
alt="Care"
/>
<div class="title">TEAMWORK</div>
<div>
Actively seeks opportunities to collaborate with and support
others. Builds relationships across the organization, shares
knowledge and experience, involve others and communicates
effectively.
</div>
</div>
</div>
<div class="box">
<div class="content">
<img
src="https://printeconline.sharepoint.com/:i:/r/sites/Marketing/Group%20Marketing%20Folder/Brand/Brand%20Materials/Values/Icons/Icons/Printec_Values_Icons_White_500x500px/Printec_Care_Icon_White_500x500px.png?csf=1&web=1&e=paSbKD"
alt="Care"
/>
<div class="title">BUILDS TRUST</div>
<div>
Gains the trust of others through honesty and authenticity. Shows
consistency between his/her words and actions, upholds
professional codes of conduct, acts in accordance with the
company’s policies, delivers on promises, and takes personal
responsibility for decisions, actions, and mistakes.
</div>
</div>
</div>
<div class="box">
<div class="content">
<img
src="https://printeconline.sharepoint.com/:i:/r/sites/Marketing/Group%20Marketing%20Folder/Brand/Brand%20Materials/Values/Icons/Icons/Printec_Values_Icons_White_500x500px/Printec_Care_Icon_White_500x500px.png?csf=1&web=1&e=paSbKD"
alt="Care"
/>
<div class="title">CARE FOR OTHERS AND INCLUSION</div>
<div>
Actively seeks opportunities to collaborate with and support
others. Builds relationships across the organization, shares
knowledge and experience, involve others and communicates
effectively.
</div>
</div>
</div>
</div>
https://learncssgrid.com/
This question already has answers here:
Equal height children of flex items
(2 answers)
Closed 3 years ago.
I'm trying to achieve a flexbox, where the row will have the titles all lined up. Requirements:
The images won't always be the same height
The description won't always be the same height
The title could be 1 row, or 3 (depending on the length)
Here is a simple fiddle:
https://jsfiddle.net/youradds/r56j4uLe/6/
As you can see this is what you get:
This is more what I'm after:
My SCSS is:
#item-wrapper {
display: flex;
justify-content: space-around;
flex-wrap: wrap;
.item-block {
background: yellow;
flex-grow: 0;
width: 350px;
margin: 2rem 1rem;
display: flex;
flex-direction: column;
justify-content: space-between;
align-content: center;
align-items: center;
.what-logo {
img {
max-height: 100%;
}
}
.text-info {
flex-grow: 1;
.desc {
padding: 1rem;
}
h2 {
flex-grow: 0;
}
}
.action-button {
margin: 0 auto;
}
}
}
.pure-img {
max-width: 100%;
height: auto;
display: block;
}
..and test HTML:
<div id="item-wrapper">
<div class="item-block">
<div class="what-logo">
<img src="https://bodywisegym.co.uk/2018/images/events/3/3-1562951826-3.png" class="pure-img">
</div>
<div class="text-info">
<h2>Zydrunas Savickas Seminar</h2>
<div class="desc">Bodywise Gym and Studios are proud to announce we are bringing the greatest strongman Zydrunas Savickas (Big Z) to Horsham for a seminar.</div>
</div>
Find out more »
</div>
<div class="item-block">
<div class="what-logo">
<img src="https://bodywisegym.co.uk/2018/images/events/7/7-1562936970-7.jpg" class="pure-img">
</div>
<div class="text-info">
<h2>Class for mums</h2>
<div class="desc">Join Quick HIIT</div>
</div>
Find out more »
</div>
<div class="item-block">
<div class="what-logo">
<img src="https://bodywisegym.co.uk/2018/images/events/6/6-1562936464-6.png" class="pure-img">
</div>
<div class="text-info">
<h2>Gratitude Day</h2>
<div class="desc">To spread the positivity you can bring a training partner along to workout with you or to attend one of our classes.</div>
</div>
Find out more »
</div>
<div class="item-block">
<div class="what-logo">
<img src="https://bodywisegym.co.uk/2018/images/events/4/4-1562951950-4.jpg" class="pure-img">
</div>
<div class="text-info">
<h2>The experience of non-duality</h2>
<div class="desc">Yoga & meditation workshop with Indian Spiritual Master Acharya Shree Shankar </div>
</div>
Find out more »
</div>
</div>
Important note: This is a responsive design, so I can't set a height on the image div (i.e min-height 600px) because while this kind of sorts it on wider screens:
...but then on smaller screens, it scales down to 1 element per row - and this then means we have a silly amount of padding between the image and the title on the entries with smaller images:
you could look for a visual compromise.
flex children do not align with flex children from another flex parent.
You may try centering tex-info and what-logo and add an average min-height on .desc
Demo below, play it in full page to test behavior and visual.
#item-wrapper {
display: flex;
justify-content: space-around;
flex-wrap: wrap;
}
#item-wrapper .item-block {
background: yellow;
max-width: 350px;
margin: 2rem 1rem;
padding:2px;/* see me */
display: flex;
flex-direction: column;
align-items: center;
}
#item-wrapper .item-block .what-logo img {
max-height: 100%;
}
#item-wrapper .item-block .text-info,
#item-wrapper .item-block .what-logo {/* update */
margin-top: auto;
}
#item-wrapper .item-block .text-info .desc {
padding: 1rem;
min-height: 4em;/* 3 lines , average */
}
#item-wrapper .item-block .text-info h2 {text-align:center}
#item-wrapper .item-block .action-button {
margin: 0 auto;
}
.pure-img {
max-width: 100%;
height: auto;
display: block;
}
<div id="item-wrapper">
<div class="item-block">
<div class="what-logo">
<img src="https://bodywisegym.co.uk/2018/images/events/3/3-1562951826-3.png" class="pure-img">
</div>
<div class="text-info">
<h2>Zydrunas Savickas Seminar</h2>
<div class="desc">Bodywise Gym and Studios are proud to announce we are bringing the greatest strongman Zydrunas Savickas (Big Z) to Horsham for a seminar.</div>
</div>
Find out more »
</div>
<div class="item-block">
<div class="what-logo">
<img src="https://bodywisegym.co.uk/2018/images/events/7/7-1562936970-7.jpg" class="pure-img">
</div>
<div class="text-info">
<h2>Class for mums</h2>
<div class="desc">Join Quick HIIT</div>
</div>
Find out more »
</div>
<div class="item-block">
<div class="what-logo">
<img src="https://bodywisegym.co.uk/2018/images/events/6/6-1562936464-6.png" class="pure-img">
</div>
<div class="text-info">
<h2>Gratitude Day</h2>
<div class="desc">To spread the positivity you can bring a training partner along to workout with you or to attend one of our classes.</div>
</div>
Find out more »
</div>
<div class="item-block">
<div class="what-logo">
<img src="https://bodywisegym.co.uk/2018/images/events/4/4-1562951950-4.jpg" class="pure-img">
</div>
<div class="text-info">
<h2>The experience of non-duality</h2>
<div class="desc">Yoga & meditation workshop with Indian Spiritual Master Acharya Shree Shankar </div>
</div>
Find out more »
</div>
</div>
forked fiddle
We have to display blocks of content in many rows with max 3 columns. Each block of content contains a heading, description, and link. We are using flexbox to display the blocks in a row such that the height of the row is taken up by the tallest element. However, we are not able to always align the link at the bottom and it always seems to be place right below each description.
How can we align the link in the bottom of each block and have each block still be the height of the tallest block using flexbox?
Here is what we have tried: https://codepen.io/userrj/pen/WYXoOO
Code explained:
each block is surrounded by .bkg--grey so you can see the block is taking the height of the tallest block as expected.
border is added to each element with flex__item so you can see how much space it is taking up.
each block contains: heading, description, and link from top down (column)
Current issue:
Desired output
We are hoping to not use float or position: absolute to get this done.
You need to make article a flex container and adjust some alignment:
article {
display: flex;
}
.flex__item > div:last-child {
margin-top:auto;
}
Full code:
.flex__item {
display: flex;
justify-content: center;
align-items: stretch;
flex: 0 1 auto;
flex-direction: column;
}
.flex__col {
display: flex;
justify-content: center;
align-items: stretch;
}
.flex__wrapper {
display: flex;
align-items: stretch;
justify-content: flex-start;
flex-wrap: wrap;
flex-direction: row;
flex: 0 1 auto;
}
.flex__item {
padding: 16px;
border: 1px solid black;
}
.bkg--grey {
background-color: #ddd;
}
.col--sm-12 {
width: 100%;
}
.col--md-6 {
width: 50%;
}
.col--lg-4 {
width: 33.33%;
}
/*added this*/
article {
display: flex;
}
.flex__item > div:last-child {
margin-top:auto;
}
/**/
[class*=col--] {
box-sizing: border-box;
padding: 16px;
}
<section class="flex__wrapper">
<div class="col--sm-12 col--md-6 col--lg-4 flex__col">
<article class="bkg--grey">
<div class="flex__item">
<div>
<h4>Some Efficiently</h4>
<p>Efficiently enhance frictionless markets without distinctive deliverables. </p>
</div>
<div>Read More</div>
</div>
</article>
</div>
<div class="col--sm-12 col--md-6 col--lg-4 flex__col">
<article class="bkg--grey">
<div class="flex__item">
<div>
<h4>Some Objectively promote</h4>
<p>Objectively promote enterprise-wide strategic theme areas rather than process-centric catalysts for change. Completely procrastinate sticky best practices and corporate sources. Distinctively unleash superior metrics via go forward alignments. Uniquely reconceptualize plug-and-play e-services through collaborative solutions. Progressively maximize adaptive experiences with. </p>
</div>
<div>Read More</div>
</div>
</article>
</div>
<div class="col--sm-12 col--md-6 col--lg-4 flex__col">
<article class="bkg--grey">
<div class="flex__item">
<div>
<h4>Completely create</h4>
<p>Completely create equity invested relationships for client-focused paradigms. Distinctively benchmark exceptional information before corporate materials. Compellingly pontificate 2.0. </p>
</div>
<div>Read More</div>
</div>
</article>
</div>
<div class="col--sm-12 col--md-6 col--lg-4 flex__col">
<article class="bkg--grey">
<div class="flex__item">
<div>
<h4>Distinctively deliver</h4>
<p>Distinctively deliver one-to-one potentialities with excellent resources. Collaboratively.</p>
</div>
<div>Read More</div>
</div>
</article>
</div>
<div class="col--sm-12 col--md-6 col--lg-4 flex__col">
<article class="bkg--grey">
<div class="flex__item">
<div>
<h4>Authoritatively facilitate</h4>
<p>Authoritatively facilitate sustainable portals through cross-platform catalysts for change. Monotonectally transform e-business total linkage without front-end action items.</p>
</div>
<div>Read More</div>
</div>
</article>
</div>
</section>
I have a design below which I am trying to replicate in HTML and CSS:
Note: I have written text Margin and Padding to make things easy to understand. It will not come in the actual design
At this moment, I am able to get this in my fiddle.
The only thing which is not matching the above design in the fiddle are the paragraphs (eg: Our main goal, Among our biggest, etc) in every box which don't have line break. I am considering boxes as every job-opening with titles (Back-end .., Front-end .., etc) and paragraphs (eg: Our main goal, Among our biggest, etc).
The CSS for every box is:
.firstrow {
display: inline-block;
width: 100%;
}
.firstrow #front-end {
text-align: center;
width: 50%;
height: 250px;
float: left;
background-repeat: no-repeat;
display: flex;
align-items: center;
background-size: 100% 100%;
justify-content: center;
}
Here is a improved version of your code, just using flexbox, without using floats or anything else.
h2 {
text-align: center;
font-size: 2.8rem;
color: #444444;
}
.row {
display: flex;
flex-wrap: wrap;
padding: 5%;
}
.row>div {
padding: 5%;
background: gray;
margin: 15px;
display: flex;
flex-flow: column wrap;
align-items: center;
justify-content: center;
text-align: center;
flex: 1;
box-sizing:border-box
}
<div class="job-openings">
<h2>Seems Interesting? Apply Now</h2>
<div class="row">
<div id="back-end">
<h3>Back-end Developer</h3>
<p> Our main goal is to build and maintain the online platform and...</p>
</div>
<div id="front-end">
<h3>Front-end Web Developer</h3>
<p>Among our biggest priorities are interface design and user experience...</p>
</div>
<div id="graphics">
<h3>Graphics Designer</h3>
<p> We believe in the power of design. Our designers are motivated, creative and...</p>
</div>
<div id="sales">
<h3>Sales & Marketing</h3>
<p>Our Marketing team is focussed on driving growth and building a brand that customers love...</p>
</div>
</div>
</div>
Op's Comment to answer:
Back-end and front-end will come in one row with graphics designer and
sales and marketing in another row.
Assuming you want to have always 2 rows, then you can use flex:0 50% instead of flex:1, in this case flex: 0 calc(50% - 30px) to take in count the margin
h2 {
text-align: center;
font-size: 2.8rem;
color: #444444;
}
.row {
display: flex;
flex-wrap: wrap;
padding: 5%;
}
.row>div {
padding: 5%;
background: gray;
margin: 15px;
display: flex;
flex-flow: column wrap;
align-items: center;
justify-content: center;
text-align: center;
flex: 0 calc(50% - 30px);
box-sizing:border-box
}
<div class="job-openings">
<h2>Seems Interesting? Apply Now</h2>
<div class="row">
<div id="back-end">
<h3>Back-end Developer</h3>
<p> Our main goal is to build and maintain the online platform and...</p>
</div>
<div id="front-end">
<h3>Front-end Web Developer</h3>
<p>Among our biggest priorities are interface design and user experience...</p>
</div>
<div id="graphics">
<h3>Graphics Designer</h3>
<p> We believe in the power of design. Our designers are motivated, creative and...</p>
</div>
<div id="sales">
<h3>Sales & Marketing</h3>
<p>Our Marketing team is focussed on driving growth and building a brand that customers love...</p>
</div>
</div>
</div>
I'm currently developing my first website. I've come to a point where I have two divs placed next to each other inside of a flexbox. Both divs have a width and height size in percentages. When I shrink the website, however, the right div overlaps the left div. If they're going to overlap I want them to be placed underneath each other. (It's about the right-side-content div overlapping the left-side-content div)
I've included my HTML and CSS code.
HTML:
<div class="content">
<div class="left-side-content">
<div class="intro">
<div class="brands">
<img src="images/logo%20ster.png" id="logo-ster"/>
</div>
<p class="top-title">Banner and endcard</p>
<h1>STER</h1>
<p class="intro-text">"STER" is a beauty, make-up and lifestyle channel on YouTube hosted by the 16 y/o Aster Marcus.</p>
<button class="view-project-button">View Project</button>
</div>
</div>
<div class="right-side-content">
<img src="images/sponsorloop-collage.png"/>
</div>
</div>
CSS:
.content {
display: flex;
align-items: center;
height: 80%;
width: 90%;
margin-left: auto;
margin-right: auto;
}
.content .left-side-content {
width: 30%;
height: 100%;
display: flex;
align-items: center;
}
.content .right-side-content {
width: 70%;
display: flex;
align-items: center;
justify-content: flex-end;
}
Add the flex-wrap property to .content.
Also, instead of using width for left and right content, use flex-basis instead, or incorporate it into the shorthand flex, as in the snippet below...
.content {
display: flex;
align-items: center;
height: 80%;
width: 90%;
margin-left: auto;
margin-right: auto;
flex-wrap: wrap;
}
.content .left-side-content {
flex: 1 0 30%;
height: 100%;
display: flex;
align-items: center;
}
.content .right-side-content {
flex: 1 0 70%;
display: flex;
align-items: center;
justify-content: flex-end;
}
<div class="content">
<div class="left-side-content">
<div class="intro">
<div class="brands">
<img src="images/logo%20ster.png" id="logo-ster" />
</div>
<p class="top-title">Banner and endcard</p>
<h1>STER</h1>
<p class="intro-text">"STER" is a beauty, make-up and lifestyle channel on YouTube hosted by the 16 y/o Aster Marcus.</p>
<button class="view-project-button">View Project</button>
</div>
</div>
<div class="right-side-content">
<img src="https://placehold.it/300x300" />
</div>
</div>