Would appreciate any help trying to get css3/html grid layout to work. I have tried the below code in IE, chrome, and Edge, and can't get it to work. Maybe there is something I have overlooked.
#grid {
display: grid;
grid-template-columns: auto 1fr;
grid-template-rows: auto 1fr auto;
}
#title {
grid-column: 1;
grid-row: 1;
}
#score {
grid-column: 1;
grid-row: 3;
}
#stats {
grid-column: 1;
grid-row: 2;
align-self: start;
}
#board {
grid-column: 2;
grid-row: 1 / span 2;
}
#controls {
grid-column: 2;
grid-row: 3;
justify-self: center;
}
<div id="grid">
<div id="title">Game Title</div>
<div id="score">Score</div>
<div id="stats">Stats</div>
<div id="board">Board</div>
<div id="controls">Controls</div>
</div>
The problem is that you are applying the grid-template-columns property to grid items. This is a grid container property. It will be ignored on grid items (unless they are also grid containers). Instead use the grid-column and grid-row properties, which apply to grid items.
Building a Responsive Grid-View First ensure that all HTML elements have the box-sizing property set to border-box . This makes sure that the padding and border are included in the total width and height of the elements. Read more about the box-sizing property in our CSS Box Sizing chapter.
You can turn on the grid button located in the div which has display: grid declared. All you have to do is go to your browser's developer tools (mine is Microsoft Edge which is based on Chromium). You will see a button like this. And then you can code and test as you wish.
The Grid implementation(s) are not widely (or hardly at all) available in any browser as of July 5, 2016.
You can enable it in:
layout.css.grid.enabled
-webkit-
-ms-
experimental Web Platform features
flag in chrome://flags
Note that the Firefox/Chrome options only enable this for you, and there's no way to force a user to enable these settings, so this would be for experimentation purposes only.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With