Answer the question
In order to leave comments, you need to log in
Vertical positioning in CSS Grid Layout?
Hello!
It turned out to be vertically positioned in the center item-4-1
in many browsers, with the exception of IE11, it seems that I wrote prefixes, but it still does not work, what's the problem?
Sketched an example for clarity: codepen.io
Thank you!
Answer the question
In order to leave comments, you need to log in
https://caniuse.com/#search=grid it says that grid is partially supported .. i.e. fucking supported
Option number 1
<div class="wrapper">
<div class="item item-1">item-1</div>
<div class="item item-2">item-2</div>
<div class="item item-3">item-3</div>
<div id="block" class="item item-4 wrapper-2">
<div class="item">item-4-1</div>
</div>
<div class="item item-5">item-5</div>
<div class="item item-6">item-6</div>
</div>
*
{
margin: 0;
padding: 0;
}
.wrapper
{
display: -ms-grid;
display: grid;
-ms-grid-columns: 1fr 15px 1fr 15px 1fr;
grid-template-columns: 1fr 1fr 1fr;
-ms-grid-rows: 1fr 15px 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr;
grid-column-gap: 15px;
grid-row-gap: 15px;
}
.wrapper-2
{
-ms-grid-columns: 1fr;
grid-template-columns: 1fr;
}
#block
{
display: flex;
flex-direction: row;
justify-content: center;
}
.wrapper-2 > .item
{
background: red;
-ms-grid-column-align: center;
justify-self: center;
margin-top: auto;
margin-bottom: auto;
}
.wrapper > .item
{
background: #cfcfff;
padding: 15px;
}
.wrapper > .item-1
{
-ms-grid-column: 1;
-ms-grid-column-span: 1;
grid-column: 1 span 1;
-ms-grid-row: 1;
-ms-grid-row-span: 1;
grid-row: 1 / span 1;
}
.wrapper > .item-2
{
-ms-grid-column: 3;
-ms-grid-column-span: 1;
grid-column: 2 span 1;
-ms-grid-row: 1;
-ms-grid-row-span: 1;
grid-row: 1 / span 1;
}
.wrapper > .item-3
{
-ms-grid-column: 5;
-ms-grid-column-span: 1;
grid-column: 3 span 1;
-ms-grid-row: 1;
-ms-grid-row-span: 1;
grid-row: 1 / span 1;
}
.wrapper > .item-4
{
-ms-grid-column: 1;
-ms-grid-column-span: 1;
grid-column: 1 span 1;
-ms-grid-row: 3;
-ms-grid-row-span: 2;
grid-row: 2 / span 2;
}
.wrapper > .item-5
{
-ms-grid-column: 3;
-ms-grid-column-span: 1;
grid-column: 2 span 1;
-ms-grid-row: 3;
-ms-grid-row-span: 2;
grid-row: 2 / span 1;
}
.wrapper > .item-6
{
-ms-grid-column: 5;
-ms-grid-column-span: 1;
grid-column: 3 span 1;
-ms-grid-row: 3;
-ms-grid-row-span: 2;
grid-row: 2 / span 1;
}
.wrapper > .item:nth-child(odd)
{
background: #cff1ff;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question