<div class="grid-container">
<div class="grid-item">
Grid item (div) to be horizontally centered within grid container
</div>
</div>
@import url('https://fonts.googleapis.com/css2?family=Open+Sans&display=swap');
:root {
--const-color-black: #000000;
--const-color-white: #FFFFFF;
--color-header: #D9A443;
--color-main-background: #F9F6F1;
--color-link: #375F9B;
}
body {
font-family: 'Open Sans', sans-serif;
color: var(--const-color-black);
}
* {
box-sizing: border-box;
}
.grid-container {
background-color: var(--color-main-background);
border: 1px solid var(--color-link);
margin: 1.0rem auto;
padding: 1.0rem 0;
width: 100%;
/* Create a 1x1 grid container */
display: grid;
grid-template-columns: 1fr;
grid-template-rows: 1fr;
}
.grid-item {
background-color: var(--color-link);
color: var(--const-color-white);
max-width: 80%;
padding: 1.0rem;
text-align: center;
/* Horizontally center grid item */
justify-self: center;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.