position text on image correctly {CSS HTML} - html

[How to position text on the image correctly? i got three blocks of text which i want to position them on the same line on the image but i struggle with it :(
#banner {
justify-content: center;
height: 600px;
margin-top: 100px;
margin-left: 10%; }
.banner-text {
color: white;
justify-content: center;
justify-content: space-around;
text-align: center;
display: inline-block;
position: absolute;
flex-direction: column; }
/*DownTown*/
.flex-text {
background-color: grey;
text-align: center;
}
html
<div id="banner"><img src="2525.jpeg">
<div class="banner-text">
<div class="flex-text text1">
<h1><b>DownTown</b> 384 West 4th St Suite 108</h1>
<div class="flex-text text2">
<h1><b>East Bayside</b> 3433 Phisherman Avenue </h1>
<div class="flex-text text3">
<h1><b>Oakdale</b> 515 Crecent avenue Second Floor </h1>
</div>
</div>
</div>
</div>
</div>
here is how it should look
]2
and that's how i did it -_-

Your html markup is not correct and instead of adding image as an img element in the #banner, add the image as a background image using css. That way, you don't need position absolute to place text over the image. After that, use flexbox for aligning the elements.
#banner {
background-image: url(https://picsum.photos/500);
background-repeat: no-repeat;
background-size: cover;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.banner-text {
color: white;
justify-content: space-around;
display: flex;
width: 100%;
flex-wrap: wrap;
}
.flex-text {
background-color: #222;
display: flex;
align-items: center;
flex-direction: column;
justify-content: space-between;
height: 180px;
padding: 20px;
width: 200px;
margin: 5px;
}
h1 {
margin: 0;
}
<div id="banner">
<div class="banner-text">
<div class="flex-text text1">
<h1>DownTown</h1>
<span>384 West 4th St</span>
<span>Suite 108</span>
<span>Portland, Maine</span>
</div>
<div class="flex-text text1">
<h1>DownTown</h1>
<span>384 West 4th St</span>
<span>Suite 108</span>
<span>Portland, Maine</span>
</div>
<div class="flex-text text1">
<h1>DownTown</h1>
<span>384 West 4th St</span>
<span>Suite 108</span>
<span>Portland, Maine</span>
</div>
</div>
</div>

Your markup is not right. So I changed it a bit. And I also changed the css accordingly and use flex for aliigning items. And instead of using img in html I use background property.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.container {
max-width: 1200px;
height: 100vh;
margin: auto;
overflow: hidden;
padding: 1rem;
background: #333;
}
#banner {
margin-top: 100px;
}
.banner-text {
display: flex;
justify-content: center;
align-items: center;
text-align: center;
color: white;
}
/*DownTown*/
.flex-text {
background-color: rgba(0, 0, 0, 0.384);
line-height: 4rem;
padding: 4rem;
margin: 0rem 2rem;
text-align: center;
}
<div class="container">
<div id="banner">
<!-- <img src="2525.jpeg" /> -->
<div class="banner-text">
<div class="flex-text text1">
<h1>DownTown</h1>
<p>384 West 4th St</p>
<p>Suite 108</p>
</div>
<div class="flex-text text2">
<h1>East Bayside</h1>
<p>3433 Phisherman Avenue</p>
<p>(Norway Corner)</p>
</div>
<div class="flex-text text3">
<h1>Oakdale</h1>
<p>
515 Crecent avenue
</p>
<p>
Second Floor
</p>
</div>
</div>
</div>
</div>

The issue you have is the root diff i.e #banner has two child. The properties on #banner doesn't indicate in any way that the two items should overlap. You are trying to achieve that through position:absolute. Which is also an approach. But here's how you can achieve what you want in two ways:
Put that image as the background property for #banner and provide the flexbox properties to banner.
body {
margin: 0;
max-width: 100%;
}
#banner {
position: relative;
height: 600px;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
#banner img {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
z-index: 1;
}
.banner-text {
position: relative;
width: 100%;
z-index: 2;
display: flex;
justify-content: space-around;
}
.flex-text {
background: #efefef;
}
h1 {
font-size: 17px;
}
<div id="banner">
<img src="https://cdn.slashgear.com/wp-content/uploads/2019/07/coffee_main_envat-1280x720.jpg">
<div class="banner-text">
<div class="flex-text text1">
<h1><b>DownTown</b><br/> 384 West 4th St Suite 108</h1>
</div>
<div class="flex-text text2">
<h1><b>East Bayside</b><br/> 3433 Phisherman Avenue </h1>
</div>
<div class="flex-text text3">
<h1><b>Oakdale</b><br/> 515 Crecent avenue Second Floor </h1>
</div>
</div>
</div>
Position your banner div relative. Then position your image as absolute so that it occupies whole width and banner-text should have relative positioning. One other thing you need to do if the text doesn't come to center is provide 100% width to the banner-text.
Hope this solves the problem

Related

How to place over centered element?

I have a little website programmed containing an area with three divs centered in the middle. I am trying to put a <h2> over it like this:
But best I could do was to place the Locations <h2> along with the divs in the center using display: flex; and flex-direction: column; in the #locationsbg but for now I just replaced it and let the Locations away.
* {
background-color: black;
font-family: Helvetica;
color: seashell;
opacity: 0.9;
font-size: 22px;
text-align: center;
}
#locations {
display: inline-flex;
background-color: transparent;
}
#locationsbg {
margin: 0 auto;
height: 500px;
width: 1200px;
background-image: url(https://content.codecademy.com/courses/freelance-1/unit-4/img-locations-background.jpg);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
display: flex;
align-items: center;
justify-content: center;
}
#locationsbg h2 {
background-color: transparent;
position: relative;
top: 40px;
}
#locations div {
max-height: 300px;
width: 300px;
display: flex;
flex-direction: column;
margin-left: 40px;
opacity: 1;
}
<section id="locationsbg">
<!--<h2>Locations</h2> This should be over the centered divs (not in the real center-->
<div id="locations">
<div>
<h3>Downtown</h3>
<p>384 West 4th St</p>
<p>Suite 108</p>
<p>Portland, Maine</p>
</div>
<div>
<h3>East Bayside</h3>
<p>3433 Phisherman's Avenue</p>
<p>(Northwest Corner)</p>
<p>Portland, Maine</p>
</div>
<div>
<h3>Oakdale</h3>
<p>515 Crescent Avenue</p>
<p>Second Floor</p>
<p>Portland, Maine</p>
</div>
</div>
</section>
Now there is a slightly awkward structure that is difficult to work with. Wrap H2 tag with div and use any properties to move the elements inside it. Highly recommend using a grid for the elements inside #locations. As far as I understand, you will need the following code fpr example:
.heading-wrapper{
width:100%;
text-align:center;
padding:15px 0;
}
<section id="locationsbg">
<div class="heading-wrapper">
<h2>Locations</h2>
</div>
<div id="locations">
<!-- ... -->
</div>
</section>
or use the same grid for splitting and centering. But I still don't understand why you use such structure, it can be made easier with less code.
Add flex-direction: column to the #locationsbg element and then remove the positioning in the h2 element. Remove this position: relative; top: 40px; from => #locationsbg h2.
* {
background-color: black;
font-family: Helvetica;
color: seashell;
opacity: 0.9;
font-size: 22px;
text-align: center;
}
#locations {
display: inline-flex;
background-color: transparent;
}
#locationsbg {
margin: 0 auto;
height: 500px;
width: 1200px;
background-image: url(https://content.codecademy.com/courses/freelance-1/unit-4/img-locations-background.jpg);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
#locationsbg h2 {
background-color: transparent;
}
#locations div {
max-height: 300px;
width: 300px;
display: flex;
flex-direction: column;
margin-left: 40px;
opacity: 1;
}
<section id="locationsbg">
<h2>Locations</h2>
<div id="locations">
<div>
<h3>Downtown</h3>
<p>384 West 4th St</p>
<p>Suite 108</p>
<p>Portland, Maine</p>
</div>
<div>
<h3>East Bayside</h3>
<p>3433 Phisherman's Avenue</p>
<p>(Northwest Corner)</p>
<p>Portland, Maine</p>
</div>
<div>
<h3>Oakdale</h3>
<p>515 Crescent Avenue</p>
<p>Second Floor</p>
<p>Portland, Maine</p>
</div>
</div>
</section>

Flexbox Wrap Not Working On 4 Of My Images

Hello Im not sure why but for some reason flexbox is not working.
I have 4 images on one section. I added flexbox wrap on the container and I also assigned flex 1
on the children images but for some reason flexbox is not working.
If anyone could help and let me know what I am doing wrong I would really appreciate it.
https://codepen.io/rubenjr005/pen/rNexOZp?editors=0100
HTML CODE
<div id="capabilities" class="bg-dark-02 py-2 angle-top-bottom-right">
<div class="capabilities-title">
<h4 class="section-title text-center">CAPABILITIES</h4>
<h3 class="lead text-center">I DO THINGS LIKE</h3>
</div>
<div class="capabilities-container">
<div class="category">
<div class="content">
<img src="img/graphic-design-icon_03.png" alt="Graphic Design" />
<div class="text-animation">
<h3 class="text-center">GRAPHIC DESIGN</h3>
</div>
</div>
</div>
<div class="category">
<div class="content">
<img src="img/Web-Design-icon_01.jpg" alt="Web Design" />
<div class="text-animation">
<h3 class="text-center">Web Design</h3>
</div>
</div>
</div>
<div class="category">
<div class="content">
<img src="img/web-development-01.png" alt="web Development" />
<div class="text-animation">
<h3 class="text-center">Web Development</h3>
</div>
</div>
</div>
<div class="category category4">
<div class="content">
<img src="img/email-development.png" alt="Email Development" />
<div class="text-animation">
<h3 class="text-center">Email Development</h3>
</div>
</div>
</div>
</div>
</div>
SCSS
#capabilities {
height: 100%;
margin-bottom: 4.5rem;
.capabilities-container {
display: flex;
flex-wrap: wrap;
// min-width: 20%;
.category {
display: flex;
// flex-direction: column;
flex: 1;
padding: 1rem;
align-items: center;
justify-content: center;
min-width: 10rem;
// width: 10rem;
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
img {
position: absolute;
top: 30%;
height: 12rem;
width: auto;
display: block;
// margin: auto;
margin-bottom: 4rem;
opacity: 0.4;
transition: 0.75s;
// padding-bottom: 4rem;
}
.text-animation {
// position: absolute;
text-align: center;
padding-top: 15rem;
transition-duration: 0.75s;
text-align: center;
left: 0;
right: 0;
// background: red;
// margin: auto;
h3 {
color: white;
text-transform: uppercase;
// margin: auto;
}
}
}
}
.category:hover .content img {
opacity: 1;
margin-bottom: 1rem;
// padding-bottom: 0rem;
// padding-bottom: 0rem;
}
.category:hover .content .text-animation {
// opacity: 1.0;
padding-top: 10rem;
}
}
}
You have to get rid of absolute positioning on your img and you'll have to use media queries.
Starting from there, you'll see the flex-wrap: wrap working.
Here is a fork : https://codepen.io/hisato/pen/vYGLLNY?editors=0100
Also, if I may add, as a general advice avoid to transition margin/padding/top/left etc. You should always look for a way to transition the transform property, it will have the best performance.

Trying to left-align text in flex containers with a flex rule

I have a section that has a list of jokes where each joke is individually contained within divs. In each joke are two paragraphs that I'm trying to align to display at the left (start of the flex container). Right now the two main issues I'm facing is that the first paragraph (Q:) is not aligning to the very start of the container
I'm trying to align the paragraphs so that both the abbreviation and question wrap to leftmost boundary of the container's content.
The second issue I'm facing is that the second paragraph (A:) keeps centering itself in the container instead of displaying on the left side. I am not sure why the first paragraph does not center itself but the second paragraph does when displaying the webpage. I've been told that this can be achieved with a single flex rule which I've been trying to find in my div p ruleset.
Overall, I am trying to achieve this expected display:
HTML
<section id="jokes">
<h2>Out Of This World Joke Inventory!</h2>
<p>Hover over each joke to see the answer!</p>
<div id="joke-cards">
<div id="sun-joke">
<img src="img/icon1.png" alt="Icon of shooting star">
<hr>
<p><span class="abbrv">Q:</span> Why did the sun go to school?</p>
<p><span class="abbrv">A:</span> <span class="answer">To get brighter!</span></p>
</div>
<div id="tick-joke">
<img src="img/icon2.png" alt="Icon of rocket blasting off">
<hr>
<p><span class="abbrv">Q:</span> What do you call a tick on the moon?</p>
<p><span class="abbrv">A:</span> <span class="answer">A luna-tick</span></p>
</div>
<div id="restaurant-joke">
<img src="img/icon3.png" alt="Icon of flag on the Moon">
<hr>
<p><span class="abbrv">Q:</span> Why did the people not like the restaurant on the moon?</p>
<p><span class="abbrv">A:</span> <span class="answer">Because there was no atmosphere.</span></p>
</div>
</div>
</section>
CSS
#joke-cards {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-evenly;
}
#joke-cards div {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 15px;
margin-left: 15px;
margin-right: 15px;
margin-bottom: 15px;
height: 400px;
width: 300px;
background-color: #9B580D;
opacity: 80%;
padding: 20px;
}
#joke-cards div img {
height: 150px;
width: 150px;
}
hr {
width: 65%;
}
div p {
align-content: flex-start;
}
.abbrv {
font-size: 28px;
color: #E0DBD7;
}
.answer {
display: none;
font-size: 24px;
color: #191919;
}
#joke-cards div:hover .answer {
display: inline;
}
Use align-items: flex-start; for the divs, width + margin for img and text-align: left; for p
img{ width: 50%; outline: 1px solid blue; margin: 0 auto; }
#joke-cards {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-evenly;
}
#joke-cards div {
display: flex;
flex-direction: column;
align-items: flex-start;
margin-top: 15px;
margin-left: 15px;
margin-right: 15px;
margin-bottom: 15px;
height: 400px;
width: 300px;
background-color: #9B580D;
opacity: 80%;
padding: 20px;
}
#joke-cards div img {
height: 150px;
width: 150px;
}
hr {
width: 65%;
}
div p {
text-align: left;
}
.abbrv {
font-size: 28px;
color: #E0DBD7;
}
.answer {
display: none;
font-size: 24px;
color: #191919;
}
#joke-cards div:hover .answer {
display: inline;
}
<section id="jokes">
<h2>Out Of This World Joke Inventory!</h2>
<p>Hover over each joke to see the answer!</p>
<div id="joke-cards">
<div id="sun-joke">
<img src="img/icon1.png" alt="Icon of shooting star">
<hr>
<p><span class="abbrv">Q:</span> Why did the sun go to school?</p>
<p><span class="abbrv">A:</span> <span class="answer">To get brighter!</span></p>
</div>
<div id="tick-joke">
<img src="img/icon2.png" alt="Icon of rocket blasting off">
<hr>
<p><span class="abbrv">Q:</span> What do you call a tick on the moon?</p>
<p><span class="abbrv">A:</span> <span class="answer">A luna-tick</span></p>
</div>
<div id="restaurant-joke">
<img src="img/icon3.png" alt="Icon of flag on the Moon">
<hr>
<p><span class="abbrv">Q:</span> Why did the people not like the restaurant on the moon?</p>
<p><span class="abbrv">A:</span> <span class="answer">Because there was no atmosphere.</span></p>
</div>
</div>
</section>
You have to wrap your paragraph tags into a container which will have place-items attribute and not each paragraph. Also, you need change display value from block to inherit for each content paragraph.
<div class="content">
<p><span class="abbrv">Q:</span> Why did the sun go to school?</p>
<p><span class="abbrv">A:</span> <span class="answer">To get brighter!</span></p>
</div>
div.content{
display: flex;
flex-direction: column;
width: 100%;
place-self: flex-start;
}
div.content p {
display:inherit;
}

column image behave as background image

I have two columns using flexbox but does not have to use flexbox. just using it at the moment but am open to other options. The left side is content with a width of 450px and the right column I have an image that needs to behave as a background image but not use css background property. Is there a way to set the image size / image column and have it overflow out of containers and not push the left column content?
setting container widths and using relative positioning but not scaling or behaving as I would like
.row--flex {
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
width: 100%;
margin: 0;
}
.content-col--450 {
max-width: 450px;
}
.content-col {
margin-bottom: auto;
margin-top: 97px;
padding-bottom: 20px;
}
.image-col {
padding-left: 10px;
}
}
.image {
width: 100%;
height: auto;
}
<div class="container container--outer">
<div class="row--flex">
<!--content-->
<div class="content-col content-col--450">
<div class="title-row">
<h2>
testing h2
</h2>
</div>
<div class="content-row">
<p class="p-margin-bottom">
testing P
</p>
<p class="lead">
download test
</p>
<button class="button--arrow">
<span class="button--text">download now</span>
</button>
</div>
</div>
<!--end content-->
<!--image-->
<div class="image-col">
<img src="/img/right-image.png" alt="right column image" class="image-test">
</div>
<!--end image-->
</div>
column 450 stay in place and image overflow out of containers and behave as BG image
You need something like this?
.row--flex {
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
width: 100%;
margin: 0;
}
.content-col--450 {
/* max-width: 450px; */
flex-basis: 450px;
}
.content-col {
margin-bottom: auto;
margin-top: 97px;
padding-bottom: 20px;
}
.image-col {
position: relative;
flex-basis: 450px;
align-self: stretch;
padding-left: 10px;
}
.image-test {
position: absolute;
top: 0;
left: 0;
z-index: -1;
width: 100%;
height: 100%;
object-fit: cover;
}
.image {
width: 100%;
height: auto;
}
<div class="container container--outer">
<div class="row--flex">
<div class="content-col content-col--450">
<div class="title-row">
<h2>
testing h2
</h2>
</div>
<div class="content-row">
<p class="p-margin-bottom">
testing P
</p>
<p class="lead">
download test
</p>
<button class="button--arrow">
<span class="button--text">download now</span>
</button>
</div>
</div>
<div class="image-col">
<img class="image-test" src="https://picsum.photos/536/354" alt="right column image">
</div>
</div>
</div>

CSS Flexbox help, getting items to align in a grid (image, title, text)

I'm working to build the following layout as seen in the image below... The goal is the image is on the left with a fixed width. The text on the right of the image is aligned accordingly and takes up the available width.
Lastly, the goal is that these items stack in a grid.
I'm having problems getting the items to align properly, here's what I have:
.feature-items {
background: #CCC;
box-sizing: border-box;
width: 100%;
padding: 0px;
}
.feature-item--wrapper {
background: #efefef;
display: inline-block;
flex-direction: row;
box-sizing: border-box;
width: 336px;
flex-wrap: wrap;
align-items: center;
justify-content: center;
}
.img-wrapper {
box-sizing: border-box;
width: 88px;
padding-right: 24px;
}
.img-wrapper,
img {
width: 64px;
height: 64px;
}
.text {
box-sizing: border-box;
padding-top: 24px;
padding-bottom: 24px;
flex: 1 1 auto;
}
<div class="feature-items">
<div class="feature-item--wrapper">
<div class="img-wrapper">
<img src="http://clipground.com/images/minecraft-server-clipart-64x64-9.png" width="64">
</div>
<div class="text">
<strong class="feature-title">Title</strong>
<p class="feature-description">This is a sentence description, hello world.</p
</div>
</div>
<div class="feature-item--wrapper">
<div class="img-wrapper">
<img src="http://clipground.com/images/minecraft-server-clipart-64x64-9.png" width="64">
</div>
<div class="text">
<strong class="feature-title">Title</strong>
<p class="feature-description">This is a sentence description, hello world.</p
</div>
</div>
<div class="feature-item--wrapper">
<div class="img-wrapper">
<img src="http://clipground.com/images/minecraft-server-clipart-64x64-9.png" width="64">
</div>
<div class="text">
<strong class="feature-title">Title</strong>
<p class="feature-description">This is a sentence description, hello world.</p
</div>
</div>
<div class="feature-item--wrapper">
<div class="img-wrapper">
<img src="http://clipground.com/images/minecraft-server-clipart-64x64-9.png" width="64">
</div>
<div class="text">
<strong class="feature-title">Title</strong>
<p class="feature-description">This is a sentence description, hello world.</p
</div>
</div>
</div>
Any help would be appreciate as to what I'm doing wrong? Thanks
to .feature-items and .feature-item--wrapper add display flex
.feature-items {
background: #CCC;
box-sizing: border-box;
width: 100%;
padding: 0px;
display: flex;
flex-wrap: wrap;
}
.feature-item--wrapper {
background: #efefef;
flex-direction: row;
box-sizing: border-box;
width: 50%;
align-items: center;
justify-content: center;
display: flex;
}
.img-wrapper {
box-sizing: border-box;
width: 88px;
padding-right: 24px;
}
.img-wrapper,
img {
width: 64px;
height: 64px;
}
.text {
box-sizing: border-box;
padding-top: 24px;
padding-bottom: 24px;
flex: 1 1 auto;
}
<div class="feature-items">
<div class="feature-item--wrapper">
<div class="img-wrapper">
<img src="http://clipground.com/images/minecraft-server-clipart-64x64-9.png" width="64">
</div>
<div class="text">
<strong class="feature-title">Title</strong>
<p class="feature-description">This is a sentence description, hello world.</p>
</div>
</div>
<div class="feature-item--wrapper">
<div class="img-wrapper">
<img src="http://clipground.com/images/minecraft-server-clipart-64x64-9.png" width="64">
</div>
<div class="text">
<strong class="feature-title">Title</strong>
<p class="feature-description">This is a sentence description, hello world.</p>
</div>
</div>
<div class="feature-item--wrapper">
<div class="img-wrapper">
<img src="http://clipground.com/images/minecraft-server-clipart-64x64-9.png" width="64">
</div>
<div class="text">
<strong class="feature-title">Title</strong>
<p class="feature-description">This is a sentence description, hello world.</p>
</div>
</div>
<div class="feature-item--wrapper">
<div class="img-wrapper">
<img src="http://clipground.com/images/minecraft-server-clipart-64x64-9.png" width="64">
</div>
<div class="text">
<strong class="feature-title">Title</strong>
<p class="feature-description">This is a sentence description, hello world.</p>
</div>
</div>
</div>
These styles worked for me (with slight modifications).
And In HTML part check with the closing 'p' tag it is not closed properly
.feature-items {
background: #CCC;
box-sizing: border-box;
width: 100%;
padding: 0px;
}
.feature-item--wrapper {
background: #efefef;
display: inline-block;
flex-direction: row;
box-sizing: border-box;
width: auto;/* changed */
flex-wrap: wrap;
align-items: center;
justify-content: center;
}
.img-wrapper {
box-sizing: border-box;
width: 88px;
padding-right: 24px;
display: inline-block;/* added*/
}
.img-wrapper,img {width: 64px;height: 64px;}
.text {
box-sizing: border-box;
padding-top: 24px;
padding-bottom: 24px;
flex: 1 1 auto;
display: inline-block;/* added*/
}
try this. You have to set flex to the main container, not just for the childrens
.feature-items {
background: #CCC;
display: flex; /* changed */
flex-flow: wrap;
width: 100%;
padding: 0px;
}
.feature-item--wrapper {
background: #efefef;
display: flex; /* added */
flex-direction: row;
box-sizing: border-box;
width: 336px;
flex-wrap: nowrap;
align-items: center;
justify-content: flex-start;
}
.img-wrapper {
box-sizing: border-box;
width: 88px;
padding-right: 24px;
}
.img-wrapper,
img {
width: 64px;
height: 64px;
}
.text {
box-sizing: border-box;
padding-top: 24px;
padding-bottom: 24px;
flex: 1 1 auto;
}
IMO Flexbox isn't really the best tool for something like this as it was originally designed for aligning items in one direction, horizontal or vertical. It makes much more sense to build a 4 x 4 grid using CSS Grid then use Flexbox to position the items horizontally inside your "feature-item-wrapper" div. See below:
body {
width: 50%; /* reduces available width so that */
margin: 0 auto; /* items take up two rows. margin centers everthing */
}
.feature-items {
display: grid;
grid-template-columns: repeat(auto-fill,minmax(300px, 1fr)); /* minimum and max column width */
grid-gap: 20px; /* seperates each grid item */
}
.feature-item--wrapper {
background: #efefef;
display: flex;
width: 100%;
}
.img-wrapper img {
padding-top: 20px;
width: 64px;
height: 64px;
}
.text {
text-align: left;
padding: 20px;
}
The top answer given, which you seem to have marked as correct, doesn't successfully stack the grid items on top of each other when on smaller devices. To make them stack I set a minimum width for the columns which forces the stack when the window reaches the set width. Also be mindful that CSS Grid isn't supported by legacy browsers.
Hope this helps :)