Grid, flex & background patterns
Created
October 24, 2020 21:14
-
-
Save mommaroodles/7db77684855f8a1e5ced426dead92f27 to your computer and use it in GitHub Desktop.
Grid, Flex, and background patterns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
As seen here: https://nz.pinterest.com/pin/223983781446706789/ --> | |
<!-- | |
This pen uses flex and grid for alignment and layout (respectively), and background gradients for the different tiles (with a couple of exceptions: style-1, style-2 and style-10). | |
--> | |
<div class="wrap"> | |
<div class="block-title"> | |
<!-- feels a little hacky wrapping every character, but makes alignment super easy without the need for JS or hacks --> | |
<div class="title-1"> | |
<span>S</span> | |
<span>C</span> | |
<span>A</span> | |
<span>N</span> | |
<span>D</span> | |
<span>I</span> | |
</div> | |
<div class="title-3"> | |
<span>N</span> | |
<span>A</span> | |
<span>V</span> | |
<span>I</span> | |
<span>A</span> | |
<span>N</span> | |
</div> | |
<div class="title-2"> | |
<span>G</span> | |
<span>R</span> | |
<span>A</span> | |
<span>P</span> | |
<span>H</span> | |
<span>I</span> | |
<span>C</span> | |
<span> </span> | |
<span>D</span> | |
<span>E</span> | |
<span>S</span> | |
<span>I</span> | |
<span>G</span> | |
<span>N</span> | |
</div> | |
</div> | |
<div class="block style-1"></div> | |
<div class="block style-2"></div> | |
<div class="block style-3"></div> | |
<div class="block style-4"></div> | |
<div class="block style-5"></div> | |
<div class="block style-6"></div> | |
<div class="block style-7"></div> | |
<div class="block style-8"></div> | |
<div class="block style-9"></div> | |
<div class="block style-10"></div> | |
<div class="block style-6"></div> | |
<div class="block style-3"></div> | |
<div class="block style-12"></div> | |
<div class="block style-1"></div> | |
<div class="block style-11"></div> | |
<div class="block style-7"></div> | |
<div class="block style-2"></div> | |
<div class="block-13"></div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//nope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$gray-lighter: #f7f7f7; | |
$gray-light: #dbdbdd; | |
$gray-dark: #aeafb3; | |
$gray-darker: #454547; | |
$pink: #e89d93; | |
$yellow: #eec71a; | |
* { | |
box-sizing: border-box; | |
} | |
body { | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
background: powderblue; | |
color: $gray-darker; | |
font-family: 'Open Sans', sans-serif; | |
} | |
.wrap { | |
background: $gray-lighter; | |
margin-top: 50px; | |
margin-bottom: 50px; | |
width: 500px; | |
border-radius: 5px; | |
overflow: hidden; | |
display: grid; | |
grid-template-columns: repeat(4, 1fr); | |
} | |
.block { | |
width: 125px; | |
height: 125px; | |
} | |
.block-title { | |
background: $gray-lighter; | |
grid-column-start: 2; | |
grid-column-end: -1; | |
grid-row-start: 3; | |
grid-row-end: 5; | |
display: flex; | |
padding: 3em 3.5em; | |
transition: padding .3s linear; | |
align-items: stretch; | |
justify-content: space-between; | |
flex-direction: column; | |
> div { | |
display: flex; | |
justify-content: space-between; | |
} | |
&:hover { | |
padding: 3em; | |
.title-1 { | |
order: 0; | |
} | |
.title-2 { | |
order: 2; | |
} | |
.title-3 { | |
order: 1; | |
} | |
} | |
} | |
.title-1, .title-3 { | |
font-weight: 800; | |
font-size: 3em; | |
} | |
.title-2 { | |
font-weight: 600; | |
font-size: 1.1em; | |
} | |
.title-3 { | |
order: 1; | |
} | |
.style-1 { | |
background: $gray-darker; | |
} | |
.style-2 { | |
//opting for classic css triangles technique here rather than backgrounds, just because | |
width: 0; | |
height: 0; | |
border: 62px solid $gray-lighter; | |
border-top-color: $gray-dark; | |
border-bottom-color: $gray-dark; | |
//to account for a pixel-rounding annoyance: | |
background: $gray-dark; | |
padding-top: 1px; | |
} | |
.style-3 { | |
background-image: linear-gradient(135deg, $pink 50%, $gray-light 50%); | |
} | |
.style-4 { | |
background-image: linear-gradient( | |
$gray-lighter, | |
$gray-lighter 7px, | |
$gray-darker 7px, | |
$gray-darker | |
); | |
background-size: 100% 14px; | |
} | |
.style-5 { | |
background-image: linear-gradient(45deg, $yellow 50%, $gray-lighter 50%); | |
} | |
.style-6 { | |
background-image: | |
linear-gradient(135deg, $gray-darker 50%, transparent 50%), | |
linear-gradient( | |
$gray-lighter, | |
$gray-lighter 7px, | |
$gray-darker 7px, | |
$gray-darker | |
); | |
background-size: 100%, 100% 14px; | |
} | |
.style-7 { | |
background: | |
linear-gradient(45deg, $gray-light 50%, transparent 50%), | |
radial-gradient($gray-darker 4px, transparent 4px), | |
radial-gradient($gray-darker 4px, transparent 4px), | |
transparent; | |
background-size: 100%, 24px 24px, 24px 24px, 100%; | |
background-position: 0 0, -2px 6px, 10px 18px, 0 0; | |
} | |
.style-8 { | |
background-image: linear-gradient(315deg, $yellow 50%, $gray-lighter 50%); | |
} | |
.style-9 { | |
background-image: linear-gradient(225deg, $pink 50%, $gray-lighter 50%); | |
} | |
.style-10 { | |
background: $gray-light; | |
} | |
.style-11 { | |
background-image: linear-gradient(45deg, $pink 50%, $gray-lighter 50%); | |
} | |
.style-12 { | |
background-image: linear-gradient(225deg, $yellow 50%, $gray-lighter 50%); | |
} | |
.block-13 { | |
background-image: linear-gradient(to right, | |
$pink, | |
$pink 4px, | |
$gray-lighter 4px, | |
$gray-lighter | |
); | |
background-size: 8px 100%; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment