Grid Position
Align, justify et place-content en Grid.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Grid Layout</title>
<style>
.grid-container {
box-sizing: border-box;
margin: 10px auto;
width: 80%;
max-width: 640px;
background-color: rgb(225, 225, 225);
aspect-ratio: 2 / 1;
display: grid;
grid-template-columns: repeat(3, auto);
grid-template-rows: repeat(3, auto);
}
.grid-container > div {
width: 50px;
height: 20px;
background-color: lightblue;
padding: 20px;
border: 1px solid grey;
}
h3 {
margin: 25px auto 0;
width: 100%;
max-width: 640px;
}
/* align-content: justify-content: */
/* start | end | center | stretch | space-around | space-between | space-evenly; */
.center-between {
place-content: center space-between;
}
.center-around {
place-content: center space-around;
}
.center-evenly {
place-content: center space-evenly;
}
.between-between {
place-content: space-between space-between;
}
.between-stretch {
place-content: space-between stretch;
}
</style>
<script>
// function grille(align, justify) {
grille = (place) => {
document.write('<div class="grid-container ' + place + '">');
for (var i = 1; i <= 9; i++) {
document.write("<div>" + i + "</div>");
}
document.write("</div>");
};
</script>
</head>
<body>
<h3>center space-between</h3>
<script>
grille("center-between");
</script>
<h3>center space-around</h3>
<script>
grille("center-around");
</script>
<h3>center space-evenly</h3>
<script>
grille("center-evenly");
</script>
<h3>space-between space-between</h3>
<script>
grille("between-between");
</script>
<h3>space-between stretch</h3>
<script>
grille("between-stretch");
</script>
</body>
</html>