Skip to content

Instantly share code, notes, and snippets.

@projected1
Created February 27, 2023 13:57
Show Gist options
  • Save projected1/b8e40997ef12f7b756044897bfe1fe66 to your computer and use it in GitHub Desktop.
Save projected1/b8e40997ef12f7b756044897bfe1fe66 to your computer and use it in GitHub Desktop.
Use CSS grid to style a card with three rows.
<style>
* {
font-family: sans-serif;
font-weight: bold;
color: white;
}
body {
display: flex;
justify-content: center;
}
.grid {
display: grid;
grid-template-rows: 25% 1fr 4rem;
width: 250px;
height: 450px;
}
div {
display: grid;
align-items: center;
justify-content: center;
padding: 1rem;
overflow: hidden;
line-height: 1.6rem;
}
div:not(:last-child) {
border-bottom: 1px dashed white;
}
div:nth-child(1) {
background-color: mediumseagreen;
}
div:nth-child(2) {
background-color: deeppink;
}
div:nth-child(3) {
background-color: darkorange;
}
</style>
<section class="grid">
<div>Header</div>
<div>Body</div>
<div>Button</div>
</section>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment