Skip to content

Instantly share code, notes, and snippets.

@yuis-ice
Created March 30, 2022 04:57
Show Gist options
  • Save yuis-ice/3abb9d5f3730e1b220b52f250c51edeb to your computer and use it in GitHub Desktop.
Save yuis-ice/3abb9d5f3730e1b220b52f250c51edeb to your computer and use it in GitHub Desktop.
Flex Blog Entries
- featured = "https://unsplash.it/600/400/?random"
.container
.blog-posts
.post.featured
%a{"href"=>"#"}
.image{"style"=>"background-image: url(#{featured})"}
.time
.date 04
.month APR
.content
%h1 Multiply created make behold fourth yielding living male very god.
%p Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quas illo tempore at eveniet adipisci harum error deserunt in sint aspernatur magni asperiores explicabo corporis ratione praesentium illum magnam esse ipsa dignissimos quaerat perferendis dolor vero? Maiores hic modi optio eaque...
.meta
.icon-comment 22 Comments
%ul.tags
%li
%li
- (1..3).each do |i|
.row.cf
- (1..rand(2) + 2).each do |j|
.post
%a{"href"=>"#"}
.image
.time
.date
= rand(30) + 1
.month MAR
.content
%h1 Man called gathering us great subdue unto herb sixth forth.
%p Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nam a nostrum nihil nulla hic laborum illum...
.meta
.icon-comment 22 Comments
%ul.tags
%li
%li
function rand(min, max) {
return Math.floor(Math.random() * max) + min;
}
document.querySelectorAll('.post:not(.featured)').forEach((post) => {
post.querySelector('.image').style.backgroundImage = `url("https://unsplash.it/300/300/?image=${rand(100, 1000)}")`;
});
@import "compass/css3";
@import url(https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,800|Merriweather:300),
url(https://markmurray.co/codepen/customstyle.css);
*, *:before, *:after { @include box-sizing(border-box); }
a, a:visited { display: block; text-decoration: inherit; color: inherit; }
html, body {
font-family: 'Open Sans', sans-serif;
font-size: 100%;
background: darken(#e8eaef, 2%);
}
$blog--height: 200px;
.container {
padding: 0.5em 1em 1em;
max-width: calc(1400px + 1em);
margin: 0 auto;
overflow: hidden;
.blog-posts {
.featured { width: 100%!important; height: 250px!important; margin: 0.5em 0 1em 0!important; .image { height: 250px!important } .content { height: 250px!important; } }
.row { display: flex; .post { &:last-child{ margin-right: 0!important; } } }
.post {
//float: left;
//width: calc(50% - 0.25em);
flex: 1;
overflow: hidden;
background: white;
height: $blog--height;
@include box-shadow(0 0 2px 0 rgba(0,0,0,0.2));
margin-right: 1em;
margin-bottom: 1em;
&:hover { @include box-shadow(0 0 3px 2px rgba(0,0,0,0.1)); .image { opacity: 0.8 } }
.image, .content { display: inline-block; position: relative;
@include transition(all 500ms ease);
}
.image {
float: left;
width: 50%;
height: $blog--height;
background-size: cover;
background-position: center center;
.time {
background: rgba(255,255,255,0.5);
width: 50px;
text-align: center;
padding: 0.5em 0;
color: #444;
.date {
font-weight: bolder;
}
.month {
font-size: 0.7rem;
}
}
}
.content {
padding: 0.5em 1em;
width: 50%;
@include box-shadow(-2px 0 2px -1px rgba(0,0,0,0.1));
height: $blog--height;
&:before {
content: '';
position: absolute;
background: white;
width: 10px; height: 10px;
top: 20%;
left: -5px;
@include transform(rotate(45deg));
@include box-shadow(-1px 0 2px -1px rgba(0,0,0,0.1));
}
h1 {
font-weight: 600;
line-height: 2;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
p {
font-weight: 300;
font-size: 0.7rem;
line-height: 1.5;
margin-bottom: 0.5em;
font-family: 'Merriweather', sans-serif;
}
.meta {
.icon-comment {
font-size: 0.7em;
line-height: 2;
margin-top: auto;
}
}
}
}
}
}
[class^="icon-"]:before{ margin-right: 0.5em; color: #3498db; }
img {
max-width: 100%;
height: auto;
}
@media screen and (max-width: 840px){
.row{
display: block!important;
.post { width: 100%; margin: 0; }
}
}
@media screen and (max-width: 600px){
.content { width: 70%!important }
.image { width: 30%!important }
h1 { text-overflow: inherit; white-space: normal; }
}
/* clearfix */
.cf:before,
.cf:after {
content: " "; /* 1 */
display: table; /* 2 */
}
.cf:after {
clear: both;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment