CSS Grid Layout - Blog Post Template
<header>
<h1 class="page-title">CSS Grid Layout using @supports with Flexbox fallback</h1>
</header>
<main>
<div class="intro">
<h1 class="post-title">How about an interesting post title with and initial-letter because we can</h1>
</div>
<div class="byline">
<p class="meta">by Stacy Kvernmo published 3 days ago</p>
</div>
<div class="social">
<a class="twitter-share-button"
href="https://twitter.com/intent/tweet?text=Hello%20world"
data-size="large"><span class="fa fa-twitter"></span></a>
<a href="https://facebook.com/#"><span class="fa fa-facebook-square"></span></a>
<a href="https://plus.google.com/#"><span class="fa fa-google-plus-square"></span></a>
</div>
<div class="summary">
<h3>TL;DR Summary</h3>
<p>Let's pretend this is a short summary of this post content.</p>
</div>
<div class="post-content">
<!-- CSS Grid Layout browser support text -->
[[[https://codepen.io/stacy/pen/f1639a51a21481925379ac4580c6fe2e]]]
<p>Content goes here in this container. <strong>Pellentesque habitant morbi tristique</strong> senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. <em>Aenean ultricies mi vitae est.</em> Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. <a href="#">Donec non enim</a> in turpis pulvinar facilisis. Ut felis.</p>
<p>Senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui in turpis pulvinar facilisis.</p>
</div>
</main>
<!-- Support Message -->
[[[https://codepen.io/stacy/pen/NbvaNY]]]
main {
display: flex;
flex-wrap: wrap;
@include bp('large') {
justify-content: flex-end;
}
@supports (display: grid) {
display: grid;
grid-gap: 1rem;
grid-template-columns: 1fr 1fr;
@include bp('large') {
grid-template-columns: repeat(4, 1fr);
}
}
}
.intro {
@include bp('large') {
flex: 0 0 calc(50% - 3rem);
margin-left: calc(25% - 3rem);
}
@supports (display: grid) {
grid-column: 1 / span 2;
@include bp('large') {
grid-column: 2 / span 2;
margin-left: 0.5rem;
}
}
}
.summary {
@include bp('large') {
order: 1;
}
@supports (display: grid) {
grid-column: 1 / span 2;
@include bp('large') {
grid-column: 4 / span 1;
}
}
}
.post-content {
@supports (display: grid) {
grid-column: 1 / span 2;
@include bp('large') {
grid-column: 2;
}
}
@include bp('large') {
flex: 0 0 calc(50% - 3rem);
@supports (display: grid) {
grid-column: 2 / span 2;
}
}
}
.byline,
.social {
flex: 0 0 calc(50% - 3rem);
@include bp('large') {
@supports (display: flex) {
flex: 0 0 calc(25% - 3rem);
}
}
}
/* // Styles for fun
// ------------------------------------------------- */
@import url('https://fonts.googleapis.com/css?family=Open+Sans:300,400,700');
body {
background: #fff;
color: hsl(235, 9%, 39%);
font-family: 'Open Sans', sans-serif;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
margin: 1rem;
}
div {
margin: 0.5rem;
padding: 0 1rem;
@include bp('large') {
@supports (display: flex) {
flex: 0 0 calc(25% - 3rem);
}
}
&:hover {
background-color: hsl(347, 12%, 98%);
}
}
.page-title {
color: hsl(320, 60%, 30%);
font-size: calc(3rem + .25vw);
font-weight: 700;
line-height: 1.3;
margin: 1rem auto;
max-width: calc(70rem + .25vw);
text-align: center;
}
.post-title {
font-weight: 300;
line-height: 1.3;
margin-bottom: 0;
margin-top: 0;
@supports (initial-letter: 2) or (-webkit-initial-letter: 2) {
&:first-letter {
color: hsl(320, 60%, 30%);
font-weight: 700;
initial-letter: 2;
-webkit-initial-letter: 2;
}
}
}
h2 {
line-height: 1.2;
}
p,
.social a,
h3 {
margin-top: 1rem;
}
a {
color: hsl(330, 50%, 50%);
&:hover {
color: hsl(334, 62%, 30%);
}
}
.social {
display: flex;
justify-content: flex-end;
a {
font-size: 1.5rem;
padding-left: 0.5rem;
padding-right: 0.5rem;
}
}
.meta {
font-family: Georgia, serif;
font-size: calc(0.7rem + 0.25vw);
font-style: italic;
}
<link href="https://codepen.io/stacy/pen/NbvaNY" rel="stylesheet" />
<link href="https://codepen.io/stacy/pen/mOrrQg" rel="stylesheet" />