<!-- Gallery -->
<main id="js-gallery" role="main" class="gallery">
<section class="gallery__body">
<div id="js-poster" class="main__gallery-poster poster">
<div class="poster__content">
<header class="poster__header">
<div class="poster__header-col">
<h1 class="poster__header-title">juni-festwochen zürich</h1>
<h2 class="poster__header-date">1959</h2>
<ul class="poster__header-spacer">
<li>tonhalle grosser saal</li>
<li>dienslag, 30.juni und</li>
<li>mittwoch, 1.juli 20.15 uhr</li>
</ul>
</div>
<div class="poster__header-col">
<ul>
<li>abschiedskonzerte</li>
<li>von</li>
<li>dr.volkmar andreae</li>
</ul>
<ul class="poster__header-spacer">
<li>i.v. beethoven</li>
<li>neunte sinfonie in d-moll</li>
</ul>
</div>
<div class="poster__header-col">
<ul>
<li>soiisten</li>
<li>eva maria rogner</li>
<li>elsa cavelli</li>
<li>libero de luca</li>
<li>heinz rehfuss</li>
<li>gemischter chor zürich</li>
</ul>
</div>
<div class="poster__header-col">
<ul>
<li>karten fr. 5.50 bis 16.50</li>
<li>vorverkauf</li>
<li>tonhalle. jecklin, kuoni</li>
<li>hug</li>
<li>dep-kasse oerlikon der</li>
<li>schweiz kreditanstalt</li>
</ul>
</div>
</header>
<section class="poster__body">
<div class="bar bar--black"></div>
<div class="bar bar--red"></div>
<div class="bar bar--middle bar--green"></div>
<div class="bar bar--black"></div>
<div class="bar bar--middle bar--red"></div>
<div class="bar bar--bottom bar--green"></div>
<div class="bar bar--black"></div>
<div class="bar bar--red"></div>
<div class="bar bar--middle bar--green"></div>
<div class="bar bar--black"></div>
</section>
</div>
<!-- .poster__content -->
</div>
<!-- .poster -->
</section>
<!-- .gallery__body -->
</main>
<!-- .gallery -->
<!-- Gallery -->
/**
* Mixins
*/
@mixin pos ($position, $top: auto, $right: auto, $bottom: auto, $left: auto) {
position: $position;
top: $top;
right: $right;
bottom: $bottom;
left: $left;
}
@mixin center($width: null, $height: null) {
position: absolute;
top: 50%;
left: 50%;
@if not $width and not $height {
transform: translate(-50%, -50%);
} @else if $width and $height {
width: $width;
height: $height;
margin: -($width / 2) #{0 0} -($height / 2)
} @else if not $height {
margin-left: -($width / 2);
transform: translateY(-50%);
width: $width;
} @else {
margin-top: -($height / 2);
transform: translateX(-50%);
height: $height;
}
}
/**
* Variables
*/
// Colors
$primary-color: #C7BAA9;
$black: #060807;
$red: #C82A1E;
$green: #67AC6D;
// Animations
$timing: cubic-bezier(0.785, 0.135, 0.150, 0.860);
$duration: 3s;
/**
* Animations
*/
@keyframes slideDown {
0% {
transform: translateY(0);
}
100% {
transform: translateY(50%);
}
}
@keyframes slideUp {
0% {
transform: translateY(0);
}
100% {
transform: translateY(-50%);
}
}
@keyframes pulse {
0% {
transform: scale(1);
}
50% {
transform: scale(.5);
}
100% {
transform: scale(1);
}
}
/**
* Base
*/
*,
*:after,
*:before {
box-sizing: border-box;
}
body {
font-family: "Helvetica Neue","Helvetica", sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-weight: bold;
}
/**
* Gallery
*/
.gallery {
@include pos(absolute, 0, 0, 0, 0);
z-index: 1;
width: 100%;
height: 100%;
overflow: hidden;
opacity: 1;
transition: $duration opacity $timing;
background: $primary-color;
background: radial-gradient(ellipse at center, lighten($primary-color, 5%) 0%, $primary-color 100%);
&.fadeOut {
opacity: 0;
}
}
.gallery__body {
@include center();
transform-origin: center center;
}
/**
* Poster
*/
.poster {
@include center();
transform-origin: center center;
display: inline-block;
vertical-align: middle;
&:before,
&:after {
z-index: -1;
position: absolute;
content: "";
bottom: 15px;
left: 8px;
width: 50%;
top: 80%;
max-width: 300px;
background: #777;
box-shadow: 0 15px 10px rgba(#000,.5);
transform: rotate(-3deg);
}
&:after {
transform: rotate(3deg);
right: 8px;
left: auto;
}
}
.poster__content {
position: relative;
width: 500px;
height: 700px;
overflow: hidden;
padding: 2%;
background-color: $primary-color;
color: $black;
line-height: 1.3;
box-shadow: 0 1px 4px 2px rgba(#000,.2);
}
.poster__header {
position: absolute;
right: 0;
bottom: 0;
left: 0;
overflow: hidden;
padding: 8px 15px;
}
.poster__header-col {
float: left;
width: 25%;
}
.poster__header-spacer {
margin-top: 10px;
}
.poster__header-title,
.poster__header-date,
.poster__header ul li {
margin: 0;
font-size: 9px;
font-weight: bold;
line-height: 1;
}
.poster__body {
transform: rotate(45deg);
position: absolute;
top: 8%;
left: 3%;
width: 94%;
height: 67%;
overflow: hidden;
div {
float: left;
}
}
.bar--black {
width: 14.2857142857%;
height: 100%;
background-color: $black;
animation: pulse $duration $timing infinite;
}
.bar--red,
.bar--green {
width: 7.14285714286%;
height: 50%;
}
.bar--red {
background-color: $red;
animation: slideDown $duration $timing infinite alternate;
}
.bar--green {
background-color: $green;
animation: slideUp $duration $timing infinite alternate;
}
.bar--middle {
margin-top: 25%;
}
.bar--bottom {
margin-top: 50%;
}
View Compiled
(function(window, document, undefined) {
'use strict';
/**
* Selectors
*/
var body = document.body,
gallery = document.getElementById('js-gallery'),
galleryWidth = gallery.offsetWidth,
galleryHeight = gallery.offsetHeight,
poster = document.getElementById('js-poster'),
posterWidth = poster.offsetWidth,
posterHeight = poster.offsetHeight,
posterPadding = '50';
/**
* Prefixed requestAnimationFrame
*/
var requestAnimationFrame = window.requestAnimationFrame
|| window.webkitRequestAnimationFrame
|| window.mozRequestAnimationFrame
|| window.msRequestAnimationFrame
|| function(callback) {
return setTimeout(callback, 1000 / 60);
};
/**
* Methods
*/
var throttle = function(callback, limit) {
var wait = false;
return function() {
if (!wait) {
callback.call();
wait = true;
setTimeout(function() {
wait = false;
}, limit);
}
};
};
var resizePoster = function() {
// Define variable
var scale;
// Get values for poster dimensions
scale = Math.min(
galleryWidth / posterWidth,
galleryHeight / posterHeight
);
// Scale Poster for larger viewports
poster.style[Modernizr.prefixed('transform')] = 'translate(-50%, -50%) ' + 'scale(' + scale + ')';
// Sync operation with browser
requestAnimationFrame(resizePoster);
};
var onResize = throttle(function() {
// Set Gallery width
galleryWidth = gallery.offsetWidth - posterPadding;
// Set Gallery height
galleryHeight = gallery.offsetHeight - posterPadding;
// Sync operation with browser
requestAnimationFrame(resizePoster);
}, 100);
/**
* Events/APIs/init
*/
// Set Gallery width
galleryWidth = gallery.offsetWidth - posterPadding;
// Set Gallery height
galleryHeight = gallery.offsetHeight - posterPadding;
// Sync operation with browser
requestAnimationFrame(resizePoster);
// Listen for resize event
window.addEventListener('resize', onResize, false);
})(window, document);
This Pen doesn't use any external CSS resources.