html - Centering absolutely positioned element in CSS Grid -


on mozilla pen works. when switch chrome breaks.

it's me or wrong browsers?

.container {    height: 500px;    width: 500px;    background-color: beige;    display: grid;    grid-template-rows: 1fr;    grid-template-columns: 1fr;  }    .container h2 {    position: absolute;    justify-self: center;    align-self: center;    grid-row: 1;    grid-column: 1;  }
<div class="container">    <h2>text</h2>  </div>

codepen link

it appears chrome has deviated spec guidance on issue.

the justify-self , align-self properties should work on absolutely-positioned child element of grid container.

9.2. grid container parent

an absolutely-positioned child of grid container out-of-flow , not grid item, , not affect placement of other items or sizing of grid.

the static position of absolutely-positioned child of grid container determined if sole grid item in grid area edges coincide padding edges of grid container.

note position affected values of justify-self , align-self on child.

so, firefox seems have right.

for other centering options see post:


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -