<!-- Gallery -->
<main id="js-gallery" role="main" class="gallery">

	<section class="gallery__body">

		<!-- Poster -->
		<div id="js-poster" class="main__gallery-poster poster">
			<div class="poster__content">

				<header class="poster__header">
					<h1 class="poster__header-title">Konstruktive Grafik</h1>
					<h2 class="poster__header-subtitle">Kunstgewerbe museum <br/>Zürich</h2>
					<ul class="poster__header-meta">
						<li>Offen: Montag 14-18</li>
						<li>Dienstag bis Freitag 10-12, 14-18, 20-22</li>
						<li>Samstag / Sonntag 10-12, 14-17</li>
						<li class="last">8. März bis 6. April 1958</li>
					</ul>
				</header>

				<ul class="poster__body">
					<li>Arbeiten</li>
					<li>von</li>
					<li>Richard P. Lohse</li>
					<li>Hans Neuburg</li>
					<li>Carlos L. Vivarelli</li>
				</ul>

				<footer class="poster__footer">
					<p>Credit copy that is too small to read unfortunately.</p>
				</footer>

				<div class="poster__rules">
					<div class="r-1">
						<svg width="500" height="500" version="1.1" xmlns="http://www.w3.org/2000/svg">
							<rect width="500" height="500" stroke="black" fill="transparent" stroke-width="55" />
						</svg>
					</div>
					<div class="r-2">
						<svg width="500" height="500" version="1.1" xmlns="http://www.w3.org/2000/svg">
							<rect width="500" height="500" stroke="black" fill="transparent" stroke-width="55" />
						</svg>
					</div>
					<div class="r-3">
						<svg width="500" height="500" version="1.1" xmlns="http://www.w3.org/2000/svg">
							<rect width="500" height="500" stroke="white" fill="transparent" stroke-width="55" />
						</svg>
					</div>
					<div class="r-4">
						<svg width="500" height="500" version="1.1" xmlns="http://www.w3.org/2000/svg">
							<rect width="500" height="500" stroke="white" fill="transparent" stroke-width="55" />
						</svg>
					</div>
				</div>

			</div>
		</div>
		<!-- Poster -->

	</section>
	<!-- .gallery__body -->

</main>
<!-- 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
 */
$primary-color: #E3C205;
$timing: cubic-bezier(0.455,  0.030, 0.515, 0.955);
$duration: 1s;


/**
 * Animations
 */
@keyframes dash {
    0% {
        stroke-dashoffset: 0;
    }
    100% {
        stroke-dashoffset: 3000;
    }
}


/**
 * 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: 0 1em;
  background-color: $primary-color;
  color: black;
  box-shadow: 0 1px 4px 2px rgba(#000,.2);
}

.poster__header {
    width: 75%;
    float: left;
    margin-top: 40%;
    overflow: hidden;
}

.poster__header-title {
    margin-bottom: .3em;
    font-size: 30px;
}

.poster__header-subtitle {
    width: 35%;
    float: left;
    font-size: 14px;
    line-height: 1;
}

.poster__header-meta {
    position: relative;
    top: 0.2em;
    width: 65%;
    float: right;
    font-size: 6px;
    line-height: 1.5;
    font-weight: bold;

    li:last-child {
        margin-top: 4px;
    }
}

.poster__body {
    position: relative;
    top: 8px;
    width: 25%;
    float: right;
    margin-top: 40%;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;

    li:nth-child(3n) {
        margin-top: 4px;
    }
}

.poster__footer {
    @include pos(absolute, 45%, auto, auto, 73.5%);
    font-size: 3px;
}

.poster__rules {
    @include pos(absolute, 0, 0, 0, 0);
    width: 100%;
    height: 100%;
    overflow: hidden;

    div {
        position: absolute;
    }
}

.smil .poster__rules div rect {
    stroke-dasharray: 1000;
    animation: dash 5s $timing infinite alternate;
}

.r-1 {
    top: -50%;
    left: 27.5%;
    z-index: 2;
}

.r-2 {
    bottom: -22%;
    left: 27.5%;
    z-index: 2;
}

.r-3 {
    top: -26%;
    left: -32%;
    z-index: 1;
}

.r-4 {
    bottom: -46%;
    left: -32%;
    z-index: 3;
}
(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);

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. //cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js