<div class="project">
<ul class="project__list">
<li class="project__item"><a href="" class="project__link">Retro</a></li>
<li class="project__item"><a href="" class="project__link">Tofu</a></li>
<li class="project__item"><a href="" class="project__link">Banjo</a></li>
<li class="project__item"><a href="" class="project__link">Pitchfork</a></li>
</ul>
<ul class="project__bg-list">
<li class="project__bg-item"></li>
<li class="project__bg-item"></li>
<li class="project__bg-item"></li>
<li class="project__bg-item"></li>
</ul>
</div>
<main>
<h1><a href="http://ettrics.com" target="_blank">Ettrics</a></h1>
<p><a href="http://ettrics.com/code/full-screen-image-layer-viewer/" target="blank">Read the article on Ettrics.com</a></p>
</main>
* {
box-sizing: border-box;
}
body {
font-family: 'Lato';
-webkit-font-smoothing: antialiased;
line-height: 1.5;
background: lighten(black, 10);
}
a {
text-decoration: none;
color: inherit;
}
ul {
list-style-type: none;
padding: 0;
margin: 0;
}
.project {
height: 100vh;
min-width: 100vw;
overflow: hidden;
position: relative;
display: flex;
align-items: center;
justify-content: center;
&__list {
position: relative;
z-index: 1;
text-align: center;
font-size: 36px;
color: white;
}
&__link {
will-change: opacity;
display: block;
margin: 24px 0;
}
&__bg-list {
position: absolute;
top: 0;
left: 0;
}
&__bg-item {
will-change: transform, opacity;
position: absolute;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
opacity: 0;
transform: scale(0.7);
transition: all 1s cubic-bezier(0.23, 1, 0.32, 1);
&--active {
opacity: 1;
transform: scale(1);
}
&:nth-child(1) {
background: url('//unsplash.it/1960/1080') center/cover;
}
&:nth-child(2) {
background: url('//unsplash.it/1930/1080') center/cover;
}
&:nth-child(3) {
background: url('//unsplash.it/1940/1080') center/cover;
}
&:nth-child(4) {
background: url('//unsplash.it/1950/1080') center/cover;
}
}
}
/* demo */
main {
position: absolute;
bottom: 0;
color: white;
padding: 24px;
opacity: 0.9;
h1 {
font-weight: 300;
margin: 0 0 12px;
}
p {
margin: 0;
a {
font-weight: bold;
}
}
}
var project = $('.project');
var pLink = project.find('.project__link');
var pBg = project.find('.project__bg-item');
var changeBg = function() {
var thisProject = $(this);
var thisProjectIndex = thisProject.parent().index();
var thisProjectBg = pBg.eq(thisProjectIndex);
// hide all backgrounds and fade out project names
pBg.removeClass('project__bg-item--active');
pLink.css('opacity', '0.4');
// reveal the project bg you hovered over and increase opacity for that name
thisProject.css('opacity', '1');
thisProjectBg.addClass('project__bg-item--active');
};
var showFirst = function() {
// when the page loads reveal the first project
pLink.css('opacity', '0.4');
pLink.parent().first().children().css('opacity', '1');
pBg.first().addClass('project__bg-item--active');
}
var init = function() {
$(document).on('ready', showFirst);
pLink.on('mouseenter', changeBg);
};
init();
As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.
Also see: Tab Triggers