@import url(http://fonts.googleapis.com/css?family=Open+Sans:400,700);
*,
*::before,
*::after {
box-sizing: border-box;
}
body {
margin: 0;
color: #666;
background-color: #f6f6f6;
font: 1em/1 'Open Sans', sans-serif;
}
a {
text-decoration: none;
}
.container {
position: absolute;
left: calc(50% - 400px);
width: 800px;
margin: 60px auto;
}
.year {
margin: 0 0 8px;
color: #548383;
text-align: center;
font-size: 4em;
}
.description {
margin: 0 0 64px;
color: #acc2c2;
text-align: center;
font-size: 2em;
}
ul {
display: flex;
flex-wrap: wrap;
width: 740px;
margin: -14px auto -14px;
padding: 0;
list-style: none;
}
/* Safari/iOS fix: Adjusting both z-index and transform on <article>
causes text anti-aliasing to die within subsequent <article>
elements during the transition. Moving z-index to the parent <li>
fixes this. */
li {
position: relative;
z-index: 1;
width: 25%;
height: 160px;
transition: z-index;
transition-delay: .4s;
}
article {
position: absolute;
top: 50%;
left: 50%;
border-bottom: 8px solid #dfe7e7;
background-color: #fff;
cursor: pointer;
transform: translate(-50%, -50%) scale(.25);
transition: transform .4s;
}
/* Firefox fix: The outline style stretches to include absolutely
positioned child elements (in this case, the offset dismiss
button). This looks weird. The fix is to have a <div> with no
child elements, position it to have the same edges as <article>,
and apply the outline style there. */
.outline {
position: absolute;
z-index: -1;
top: 0;
bottom: -8px;
left: 0;
right: 0;
}
article:focus {
outline: none;
}
article:focus .outline {
outline: 4px solid #dab08c;
}
.dismiss {
display: block;
opacity: 0;
position: absolute;
top: -28px;
right: -28px;
width: 48px;
height: 48px;
border: 4px solid #fff;
border-radius: 50%;
color: #fff;
background-color: #666;
cursor: pointer;
transition: opacity...
JavaScript
function activate(e) {
var $wrapper = $(e.currentTarget).parent();
$wrapper
.addClass('active')
.siblings().addClass('inactive');
}
function dismiss(e) {
var $wrapper = $(e.currentTarget).closest('li');
$wrapper
.removeClass('active')
.siblings().removeClass('inactive');
e.stopPropagation();
}
function checkKey(e) {
var $wrapper = $(e.currentTarget).parent();
var isActive = $wrapper.hasClass('active');
if (isActive && (e.keyCode === 13 || e.keyCode === 27)) {
// active and hit enter or escape
dismiss(e);
} else if (!isActive && e.keyCode === 13) {
// not active and hit enter
activate(e);
}
}
$('article').on({
'click': activate,
'blur': dismiss,
'keyup': checkKey
});
$('.dismiss').on('click', dismiss);
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.