A Pen by David Rogers on CodePen.
Created
February 16, 2015 21:07
-
-
Save al-the-x/be2f49bb01ff46a64e28 to your computer and use it in GitHub Desktop.
PwQvNp
This file contains hidden or 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
<nav class="boxes"> | |
<a v-repeat="post: related" href="#" style="background-image: url({{post.image || random()}})"> <h4>{{post.title}}</h4> </a> | |
</nav><!-- .boxes --> |
This file contains hidden or 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
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); | |
} |
This file contains hidden or 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
.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