I've a CSS Grid, and I'm trying to set the justify-items property to start.
This (or any of the other properties relating to it) aren't working and in my text editor (atom) it is showing as grayed out which usually means an error.
I've looked at the specification and this property is definitely part of the spec and have even found a video tutorial of it working.
When I use it though it doesn't work and I can't get my head around why.
When I have copied the code to codepen it still does not work.
The codepen here: https://codepen.io/emilychews/pen/EvLPgJ
.gridwrapper {
background: #e6e6e6;
display: grid;
grid-template-columns: repeat(8, 1fr);
grid-auto-rows: 100px;
grid-row-gap: 10px;
grid-column-gap: 10px;
justify-items: start; /* THIS LINE ISN'T WORKING */
align-items: stretch;
}
.gridwrapper div:nth-child(1) {
grid-column: 1 / 4;
}
.gridwrapper div:nth-child(6) {
grid-column: 1 / 3;
}
.gridwrapper div {
padding: 1em;
background: red;
border: white;
width: 100%;
color: white;
box-sizing: border-box;
}
.gridwrapper div:nth-child(odd) {
background: blue;
}
<div class="gridwrapper">
<div class="grid double-col double-row">1</div>
<div class="grid">2</div>
<div class="grid">3</div>
<div class="grid">4</div>
<div class="grid">5</div>
<div class="grid">6</div>
<div class="grid">7</div>
<div class="grid">8</div>
</div>
The justify-items property aligns grid items by distributing free space in the columns (not the overall container).
In this case, however, there is no free space because each item occupies the full width of the column.
.gridwrapper div { width: 100% }
When you remove that rule, justify-items works.
Here's a more complete explanation:
The difference between justify-self, justify-items and justify-content in CSS Grid
revised codepen
.gridwrapper {
background: #e6e6e6;
display: grid;
grid-template-columns: repeat(8, 25px); /* adjustment; otherwise 1fr... */
grid-auto-rows: 100px; /* all free space */
grid-row-gap: 10px;
grid-column-gap: 10px;
justify-content: end; /* adjustment */
align-items: stretch;
}
.gridwrapper div:nth-child(1) {
grid-column: 1 / 4;
}
.gridwrapper div:nth-child(6) {
grid-column: 1 / 3;
}
.gridwrapper div {
padding: 1em;
background: red;
border: white;
/* width: 100%; */
color: white;
box-sizing: border-box;
}
.gridwrapper div:nth-child(odd) {
background: blue;
}
<div class="gridwrapper">
<div class="grid double-col double-row">1</div>
<div class="grid">2</div>
<div class="grid">3</div>
<div class="grid">4</div>
<div class="grid">5</div>
<div class="grid">6</div>
<div class="grid">7</div>
<div class="grid">8</div>
</div>
Related
This question already has answers here:
Why can't an element with a z-index value cover its child?
(5 answers)
Closed 2 years ago.
I've searched around for other answers but can't seem to fin one specifically... I'm using z-index correctly so I don't get why this is happening. That line you see in the example is supposed to go under the icon and over the sidebar but it is not.
I've tried so far
Fiddling with the z-indexes
Giving the icon in question position absolute
placing the !important keyword on the z-index property
.
.container {
background-color: #d9d8d7;
width: 600px;
height: 500px;
display: grid;
grid-template-rows: repeat(6, 1fr);
grid-template-columns: repeat(6, 1fr);
grid-gap: 5px;
}
.text-container {
background: pink;
grid-column: 3 / -1;
grid-row: 1 / 3;
display: grid;
grid-template-rows: repeat(5, 1fr);
grid-template-columns: repeat(5, 1fr);
grid-gap: 5px;
}
.top-left-container {
grid-column: 1 / 4;
grid-row: 1 / 4;
position: relative;
background-color: orange;
/* position:relative; */
}
.horizontal-line {
position: absolute;
bottom: 75%;
left:-150%;
height: 2px;
width: 300%;
z-index: ;
background-color: black;
/* z-index level 2 "middle" */
z-index: 10;
}
.heading {
/* background-color:yellow; */
grid-column: 1 /-1;
grid-row: 1 / 2;
}
.sidebar {
background-color: lightblue;
grid-row: 1 / -1;
grid-column: 1 / 2;
display: flex;
flex-direction: column;
justify-content: start;
align-items: center;
/* z-index level 1 */
z-index: 5;
}
.sidebar__wrapper {
display: flex;
flex-direction: column;
/* background-color: red; */
}
.sidebar__icon {
margin: 10px;
height: 50px;
width: 50px;
z-index: 50;
/* z-index level 3 Why wont'this cover the div
that has a higher z-index than it */
z-index: 15;
}
<div class="container">
<div class="sidebar">
<div class="sidebar__wrapper">
<img src="https://cdn0.iconfinder.com/data/icons/images-icons-rounded/110/Image-Focus-512.png" alt="" class="sidebar__icon">
<img src="https://cdn0.iconfinder.com/data/icons/images-icons-rounded/110/Image-Focus-512.png" alt="" class="sidebar__icon">
<img src="https://cdn0.iconfinder.com/data/icons/images-icons-rounded/110/Image-Focus-512.png" alt="" class="sidebar__icon">
</div>
</div>
<div class="text-container">
<div class="top-left-container">
<div class="heading">Header Here</div>
<div class="horizontal-line"></div>
</div>
</div>
</div>
So there are four things about z-index:
the lower in the code the higher the placement
adding a transform or opacity will give new z-index context (meaning higher yet again)
positioning an element will do the same as number 2
And lastly, as is in your case, a child element will inherit and be limited by its parent element if its parent element has a z-index set
The solutions:
Either take the child div out, and make it a sibling to the competing z-index div on the page (in your case that line) *recommended
Remove z-index context on parent element, so child again can be free
Give the element you want to stand out one more z-index
I added z-index .sidebar__wrapper class more then .horizontal-line class
.container {
background-color: #d9d8d7;
width: 600px;
height: 500px;
display: grid;
grid-template-rows: repeat(6, 1fr);
grid-template-columns: repeat(6, 1fr);
grid-gap: 5px;
}
.text-container {
background: pink;
grid-column: 3 / -1;
grid-row: 1 / 3;
display: grid;
grid-template-rows: repeat(5, 1fr);
grid-template-columns: repeat(5, 1fr);
grid-gap: 5px;
}
.top-left-container {
grid-column: 1 / 4;
grid-row: 1 / 4;
position: relative;
background-color: orange;
/* position:relative; */
}
.horizontal-line {
position: absolute;
bottom: 75%;
left:-150%;
height: 2px;
width: 300%;
background-color: black;
/* z-index level 2 "middle" */
z-index:10;
}
.heading {
/* background-color:yellow; */
grid-column: 1 /-1;
grid-row: 1 / 2;
}
.sidebar {
background-color: lightblue;
grid-row: 1 / -1;
grid-column: 1 / 2;
display: flex;
flex-direction: column;
justify-content: start;
align-items: center;
/* z-index level 1 */
}
.sidebar__wrapper {
display: flex;
flex-direction: column;
z-index: 11;
/* background-color: red; */
}
.sidebar__icon {
margin: 10px;
height: 50px;
width: 50px;
z-index: 50;
/* z-index level 3 Why wont'this cover the div
that has a higher z-index than it */
z-index: 15;
}
<div class="container">
<div class="sidebar">
<div class="sidebar__wrapper">
<img src="https://cdn0.iconfinder.com/data/icons/images-icons-rounded/110/Image-Focus-512.png" alt="" class="sidebar__icon">
<img src="https://cdn0.iconfinder.com/data/icons/images-icons-rounded/110/Image-Focus-512.png" alt="" class="sidebar__icon">
<img src="https://cdn0.iconfinder.com/data/icons/images-icons-rounded/110/Image-Focus-512.png" alt="" class="sidebar__icon">
</div>
</div>
<div class="text-container">
<div class="top-left-container">
<div class="heading">Header Here</div>
<div class="horizontal-line"></div>
</div>
</div>
</div>
I have a grid container and I want to align three divs like this, also doing them responsive (all stacked). I don't have the heights of the divs.
It would be two columns, in one two rows (two divs one below another), in another column a div centered vertically having in mind the height of the two first divs.
I can use grid or flexbox.
Thanks
Using Flexbox:
.wrapper {
width: 400px;
border: 2px solid black;
height: 300px;
display: flex;
flex-wrap: wrap;
flex-direction: column;
justify-content: center;
align-items: center;
}
.child {
height: 100px;
width: 150px;
border: 1px solid black;
margin-top: 20px;
margin-bottom: 20px;
}
<div class="wrapper">
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
</div>
and also grid :
Example from2 columns and the third element spanning through 2 rows and margin itself in the middle.
section {
display: grid;
grid-template-columns: repeat(2, minmax(270px, 1fr));/* or any value you need */
grid-gap: 2em;/* or any value you need */
padding: 2em;/* or any value you need */
counter-reset: divs; /*demo*/
width:max-content;/* or any value you need */
margin:auto;/* or any value you need */
}
div {
border: solid red;
min-height: 30vh;/* or any value you need */
width: 270px;/* or any value you need */
display: flex; /* demo*/
}
div {
margin-left: auto;
}
div:nth-child(3) {
grid-column: 2;
grid-row: 1 / span 2;
margin: auto 0;
}
/*demo*/
div:before {
counter-increment: divs;
content: counter(divs);
margin: auto;
font-size: 3em;
}
<section>
<div></div>
<div></div>
<div></div>
</section>
To play with the grid system, you can use : https://css-tricks.com/snippets/css/complete-guide-grid/ / http://gridbyexample.com/ and https://codepen.io/pen/ for the playground.
Here's a jsfiddle: https://jsfiddle.net/5csL2dqy/
.container {
display: flex;
flex-direction: row;
width: 100%;
}
.right {
display: inherit;
align-items: center;
}
.a, .b, .c {
box-sizing: border-box;
width: 150px;
margin: 20px;
border: 1px solid black;
}
<div class="container">
<div class="left">
<div class="a">
<p>
First div
</p>
</div>
<div class="b">
<p>
second div
</p>
</div>
</div>
<div class="right">
<div class="c">
<p>
Third div
</p>
</div>
</div>
</div>
You use the following inline-flex styles
#media only screen and (min-width: 600px) {
.container {
display: inline-flex;
}
.container div {
border: 1px solid red;
padding: 1em;
margin: 1em;
}
.container>div+div {
margin: auto;
}
}
#media only screen and (max-width: 600px) {
.container div:not(first-child) {
border: 1px solid red;
}
}
<div class="container">
<div>
<div>
1
</div>
<div>
2
</div>
</div>
<div>
3
</div>
</div>
This is one of only two answers with equal width/height gaps. G-Cyr's is the other:
.grid{
display: grid;
grid-template-columns: repeat(9,1fr);
grid-template-rows: repeat(7, 1fr);
height: 90vh;
width: 120vh;
}
.grid > div{
border: solid 3px orangered;
font: 26px sans-serif;
display: flex;
align-items:center;
justify-content:center;
}
.grid > div:nth-child(1){
grid-row: 1/span 3;
grid-column: 1/span 4;
}
.grid > div:nth-child(2){
grid-row: 3/span 3;
grid-column: 6/span 4;
}
.grid > div:nth-child(3){
grid-row: 5/span 3;
grid-column: 1/span 4;
}
<div class="grid">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
I have this Css grid, with grid items, which with chrome can i easilty be centered by applying justify-items:center or that kind of magic.
But this solution does not seem to work in IE, it keeps being stuck to the left side.
https://codepen.io/anon/pen/jjgmNX
HTML:
<div class="grid-container">
<div class="item-1">1</div>
<div class="item-2">2</div>
<div class="item-3">3</div>
<div class="item-4">4</div>
</div>
css:
.grid-container {
display: grid;
grid-template-columns: repeat(3,1fr);
grid-gap: 20px;
justify-items: center;
}
.item-1 {
background-color: rgba(200,520,266,.75);
border-color: #b4b4b4;
grid-column: 1;
grid-row: 1;
}
.item-2 {
background-color: rgba(145,520,0,.75);
grid-gap: 20px;
}
.item-3 {
background-color: rgba(145,520,0,.75);
grid-column: 3;
grid-row: 1;
}
.item-4 {
background-color: rgba(0,0,0,.25);
border-color: transparent;
grid-column: 2;
grid-row: 2;
}
How do i center the child divs - both supported in IE and chrome ?
You can use flexbox instead of grid that has good support on the browsers.
.grid-container {
display: flex;
justify-items: center;
align-items: center;
flex-wrap: wrap;
}
.item-1 {
flex: 1 1 33.33%;
background-color: rgba(200,520,266,.75);
border-color: #b4b4b4;
}
.item-2 {
flex: 1 1 33.33%;
background-color: rgba(145,520,0,.75);
}
.item-3 {
flex: 1 1 33.33%;
background-color: rgba(145,520,0,.75);
}
.item-4 {
flex-basis: 33.33%;
/* important */
margin: auto;
background-color: rgba(0,0,0,.25);
border-color: transparent;
}
justify-items isn't supported in IE for display: grid. https://developer.mozilla.org/en-US/docs/Web/CSS/justify-items#Support_in_Grid_layout
A tag soup workaround is to have the sub containers with display:flex, as justify-items is supported for that: or just use flexbox exclusively.
I'm trying to sort out a css grid to fit my imgs on this tribute page project from free code camp. I managed to do the grid as I wanted to but I can't seem to fit the images perfectly in each cell. Some of them are not filling the entire cell and others are exceeding it. This is the code:
.img-div-container {
display: grid;
grid-template-columns: 50% 25% 25%;
grid template-rows: 5px 5px;
margin-left: 100px;
margin-right: 100px;
grid-column-gap: 5px;
align-content: stretch;
justify-content: stretch;
background: hsla(199, 19%, 62%, 0.21);
border: 2px outset hsla(199, 19%, 62%, 0.21)
}
.image-bigger {
grid-column: 1/2;
grid-row: 1/3;
place-self: stretch;
;
}
.image-wider {
grid-column: 2/4;
grid-row: 2/3;
place-self: end stretch;
width: 95%;
}
.image-normal,
.image-bigger,
{
place-self: stretch;
justify-self: flex-start;
}
img {
width: 100%;
height: 87%;
}
.normal {
width: 100%;
height: auto;
}
<div class="img-div-container">
<div class="image-bigger"><img src="http://s2.glbimg.com/eP3_5jDhj_6tF-nyyiGpPOKdHNh8tT68kXTqIHZg3lBrXaqmUDsPSdlfxwreNWMq/e.glbimg.com/og/ed/f/original/2012/10/29/754_carlos_marighella.jpg"></div>
<div class="image-normal"><img class="resize" src="https://drupal-multisite-s3.s3-us-west-2.amazonaws.com/files/marighella2.jpg"></div>
<div class="image-normal"><img class="normal" src="http://www.cartografiasdaditadura.org.br/files/2014/12/Carlos_Marighella.jpg"></div>
<div class="image-wider"><img class="normal" id="bigode" src="http://memoriasdaditadura.org.br/wp-content/uploads/2014/11/mariguella4-e1471390559677-600x286.jpg"></div>
</div>
I'm sorry the code got a little bit messy when trying to fix this.
The biggest change I did is to add the property object-fit to your images:
img {
width: 100%;
height: 100%;
display: block;
object-fit: cover;
}
https://www.w3schools.com/css/css3_object-fit.asp
For the rest, I have only commented on some of your rules that I considered unnecessary to this work:
.img-div-container {
display: grid;
grid-template-columns: 50% 25% 25%;
/*grid-template-rows: 5px 5px;*/
margin-left: 100px;
margin-right: 100px;
grid-gap: 5px;
/*align-content: stretch;
justify-content: stretch;*/
background: hsla(199, 19%, 62%, 0.21);
border: 2px outset hsla(199, 19%, 62%, 0.21);
overflow:hidden;
}
.image-bigger {
grid-column: 1/2;
grid-row: 1/3;
/*place-self: stretch;*/
}
.image-wider {
grid-column: 2/4;
grid-row: 2/3;
/*place-self: end stretch;
width: 95%;*/
}
/*.image-normal,
.image-bigger,
{
place-self: stretch;
justify-self: flex-start;
}*/
img {
width: 100%;
height: 100%;
display:block;
object-fit: cover;
}
/*.normal {
width: 100%;
height: auto;
}*/
<div class="img-div-container">
<div class="image-bigger"><img src="http://s2.glbimg.com/eP3_5jDhj_6tF-nyyiGpPOKdHNh8tT68kXTqIHZg3lBrXaqmUDsPSdlfxwreNWMq/e.glbimg.com/og/ed/f/original/2012/10/29/754_carlos_marighella.jpg"></div>
<div class="image-normal"><img class="resize" src="https://drupal-multisite-s3.s3-us-west-2.amazonaws.com/files/marighella2.jpg"></div>
<div class="image-normal"><img class="normal" src="http://www.cartografiasdaditadura.org.br/files/2014/12/Carlos_Marighella.jpg"></div>
<div class="image-wider"><img class="normal" id="bigode" src="http://memoriasdaditadura.org.br/wp-content/uploads/2014/11/mariguella4-e1471390559677-600x286.jpg"></div>
</div>
Try to give your grid grid-template-areas
and then grid-area to each div accordingly,
for example:
HTML
<div class="grid-container">
<div class="verticalphoto"></div>
<div class="photo1"></div>
<div class="photo2"></div>
</div>
CSS
.grid-container {
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr;
grid-template-areas:
"verticalphoto photo1 . ." "verticalphoto photo2 . ." ". . . .";
}
.verticalphoto { grid-area: verticalphoto; }
.photo1 { grid-area: photo1; }
.photo2 { grid-area: photo2; }
to fit the image, try,
img {
width: 100%;
height: 100%;
display: block;
object-fit: cover;
}
you are using
display: grid;
grid-template-columns: 50% 25% 25%;
grid template-rows: 5px 5px;
which seems coherent 3 colums and 2 rows.
I would use
display:grid;
grid-template-columns: 50% 25% 25%;
grid-template-rows:1fr 1fr;
to avoid a fixed value and let the browser manage sizing for the rows.
Then , you use
.image-wider {
grid-column: 2/4;
grid-row: 2/3;
}
Which would work perfectly with a grid-template-areas if areas described 4 columns and 3 rows, which is obviously not the case here (you setted 3 columns and 2 rows ) .
I would safely use here for a grid-template-columns / grid-template-rows :
.image-wider {
grid-column: 2 / span 2; /* set in the second column and span through 2 columns */
grid-row: 2;/* not really needed here since it is already standing in the last empty grid cell avalaible */
}
tell only how many cell there is to span through instead telling go from cell 2 to cell 4 (grid-template-areas was not set ! )
When using flex or grid, if you are unfamiliar with it, make it into steps as simple as possible .
You could have start to build your grid layout with a few extra class to make it easier to read at first and easier to tune later.
the row-gap also seems to me more alike a margin-bottom for the first 2 small grid.
code example broken into pieces to show where to dispatch each containers ;)
.grid {
display:grid;
margin:0 100px;
grid-template-columns: 50% 25% 25%;
grid-template-rows:1fr 1fr;
}
.c1 {
grid-column:1;
}
.c2 {
grid-column:2;a
}
.c3 {
grid-column:3;
}
.c23 {
grid-column:2/ span 3;
}
.r1 {
grid-row:1;
}
.r2 {
grid-row:2;
}
.r12 {
grid-row:1/ span2;
}
.image-normal {
margin-bottom:5px;
}
/* whatever size is needed , object-fit can also be used to clip and avoid pixel stretching */
img {
height:100%;
width:100%;
}
<div class="img-div-container grid">
<div class="image-bigger c1 r12">
<img src="http://s2.glbimg.com/eP3_5jDhj_6tF-nyyiGpPOKdHNh8tT68kXTqIHZg3lBrXaqmUDsPSdlfxwreNWMq/e.glbimg.com/og/ed/f/original/2012/10/29/754_carlos_marighella.jpg">
</div>
<div class="image-normal c2 r1">
<img class="resize" src="https://drupal-multisite-s3.s3-us-west-2.amazonaws.com/files/marighella2.jpg">
</div>
<div class="image-normal c3 r1">
<img class="normal" src="http://www.cartografiasdaditadura.org.br/files/2014/12/Carlos_Marighella.jpg">
</div>
<div class="image-wider c23 r2">
<img class="normal" id="bigode" src="http://memoriasdaditadura.org.br/wp-content/uploads/2014/11/mariguella4-e1471390559677-600x286.jpg">
</div>
</div>
Looks like you mixed grid-template-areas and grid-template-rows (-columns) to fill your grid .
This question already has answers here:
Centering in CSS Grid
(9 answers)
Closed 3 years ago.
Using CSS-Grid, I try to put my items in the center of a grid cell, without shrinking them completely to only the content. Is this possible?
I made a simple example on stackblitz. You can see that the items there don't fill the entire grid-cell with the background color. What is the proper way to get that working? I can remove the justify-items/align-items classes, but then the content isn't centered anymore.
https://stackblitz.com/edit/angular-8bggtq?file=app/app.component.html
Cells filled, but content not in center:
Cells not filled, but content is centered:
.wrapper {
display: grid;
height: 100vh;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr;
justify-items: center;
align-items: center;
}
.item {
//justify-self: stretch;
//align-self: stretch;
}
.one {
background: red;
}
.two {
background: pink;
}
.three {
background: violet;
}
.four {
background: yellow;
}
.five {
background: brown;
}
.six {
background: green;
}
html,
body {
margin: 0;
}
<div class="wrapper">
<div class="item one">1</div>
<div class="item two">2</div>
<div class="item three">3</div>
<div class="item four">4</div>
<div class="item five">5</div>
<div class="item six">6</div>
</div>
The HTML structure of a grid container has three levels:
the container
the items (the children of the container)
the content (the grandchildren of the container and children of the items)
The problem you're having is that you're taking a two-level approach instead of the correct three-level approach. When you set align-items and justify-items on the container, they apply to the grid items, not to the content.
That's exactly what you are seeing: The grid items are being vertically and horizontally centered.
If you want to center the grid item children (the content), you need to specify that on the items. You can repeat on the items what you did on the container:
.item {
display: grid;
justify-items: center;
align-items: center;
}
Or, if you don't need grid layout in the items, here's another simple method:
.item {
display: flex;
justify-content: center;
align-items: center;
}
The above concepts apply to flex containers, as well.
For a more complete explanation and other centering methods see this post: Centering in CSS Grid
.wrapper {
display: grid;
height: 100vh;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr;
}
.item {
display: flex;
align-items: center;
justify-content: center;
}
.one { background: red; }
.two { background: pink; }
.three { background: violet; }
.four { background: yellow; }
.five { background: brown; }
.six { background: green; }
body { margin: 0; }
<div class="wrapper">
<div class="item one">1</div>
<div class="item two">2</div>
<div class="item three">3</div>
<div class="item four">4</div>
<div class="item five">5</div>
<div class="item six">6</div>
</div>
I would say the only way to do that just with CSS-grid is to insert a additional element- / grid-level.
However, I would also say that here - as #Zuber has already showed - the combination between grid and flexbox is the best way to achieve what you want.
Grid is designed to be used with flexbox, not instead of it
Ollie Williams: Things I’ve Learned About CSS Grid Layout
Pure Grid-example:
* { margin: 0; padding: 0; box-sizing: border-box; }
body { margin: 20px; }
.wrapper {
height: 100vh;
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr;
grid-gap: 20px;
}
.wrapper__item {
display: grid;
align-items: center;
justify-items: center;
background: gray;
color: white;
font-size: 2em;
}
<div class="wrapper">
<div class="wrapper__item"><span>1</span></div>
<div class="wrapper__item"><span>2</span></div>
<div class="wrapper__item"><span>3</span></div>
<div class="wrapper__item"><span>4</span></div>
<div class="wrapper__item"><span>5</span></div>
<div class="wrapper__item"><span>6</span></div>
</div>
Grid- & Flexbox-example:
* { margin: 0; padding: 0; box-sizing: border-box; }
body { margin: 20px; }
.wrapper {
height: 100vh;
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr;
grid-gap: 20px;
}
.wrapper__item {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
background: gray;
color: white;
font-size: 2em;
}
<div class="wrapper">
<div class="wrapper__item">1</div>
<div class="wrapper__item">2</div>
<div class="wrapper__item">3</div>
<div class="wrapper__item">4</div>
<div class="wrapper__item">5</div>
<div class="wrapper__item">6</div>
</div>
you need to add some css in the class "item"
.item {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
Try with justify-self: center or text align:center if it is only text.