Using CSS Grid Layout, I create a site whose layout changes a little with screen size.
Here, in order to keep the content (pink area) in the CSS Grid Layout central, I did the following styling.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.text {
color: #fff;
}
.bg {
background-color: #6c757d;
}
footer {
width: 100%;
display: grid;
grid-template-columns: minmax(20%, 1fr) auto minmax(20%, 1fr);
grid-template-rows: repeat(3, auto);
}
h1,
dl {
grid-column: 2;
background-color: pink;
}
p.h6 {
grid-row: 3;
grid-column: 3;
overflow-wrap: break-word;
}
@media (max-width: 800px) {
p.h6 {
grid-column: 2;
}
}
body>p {
text-align: center;
}
<footer class="bg text">
<h1>
heading
</h1>
<dl class="h6">
<dt>word1</dt>
<dd>desc1</dd>
<dt>word2</dt>
<dd>desc2</dd>
</dl>
<p class="h6">COPYRIGHT(C)loooooooooooooooooooooooooongtext</p>
</footer>
<p>↑<br>true center</p>
This seems to work well when the width is wide, but when the width is smaller, the pink area deviates from the "true center".
This also shows that minmax (20%, 1fr) does not work well.
How can I keep this pink area centered? Also, is there a better way than the one I thought above? (With CSS Grid Layout)