Skip to content

Instantly share code, notes, and snippets.

@al-the-x
Created February 16, 2015 21:07
Show Gist options
  • Save al-the-x/be2f49bb01ff46a64e28 to your computer and use it in GitHub Desktop.
Save al-the-x/be2f49bb01ff46a64e28 to your computer and use it in GitHub Desktop.
PwQvNp
<nav class="boxes">
<a v-repeat="post: related" href="#" style="background-image: url({{post.image || random()}})"> <h4>{{post.title}}</h4> </a>
</nav><!-- .boxes -->
new Vue({
el: '.boxes',
data: {
related: [
{ title: 'A Post Title',
image: loremPixel()
},
{ title: 'Another Post',
},
{ title: 'A Post with a Really Long Title',
},
{ title: 'Yep, another post.',
}
]
},
methods: {
random: loremPixel
}
})
function loremPixel(){
return 'http://lorempixel.com/400/400/abstract?' + Math.floor(Math.random() * 1000);
}
.boxes {
width: 100%;
a {
color: white;
background-image-size: cover;
display: block; float: left;
position: relative;
width: 25%; padding-bottom: 25%;
h4 {
font-size: 200%; text-align: right;
position: absolute; bottom: 0;
}
}
a:before {
content: ' ';
display: block;
background-color: red;
opacity: 0.4;
position: absolute;
top: 0; right: 0; bottom: 0; left: 0;
}
a:hover:before {
opacity: 0; transition: opacity 0.5s;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment