<!-- 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">
					<h1>1974-1975<br>Annual<br>Report</h1>
					<h2>Canadian<br>Broadcasting<br>Corporation</h2>
					<h3>Société<br>Radio–<br>Canada</h3>
				</header>

				<section class="poster__body">
					<div class="poster__body-layer-1">
						<div class="circle"></div>
						<div class="circle"></div>
						<div class="circle"></div>
						<div class="circle"></div>
						<div class="circle"></div>
						<div class="circle"></div>
						<div class="circle"></div>
						<div class="circle"></div>
						<div class="circle"></div>
					</div>

					<div class="poster__body-layer-2">
						<div class="circle"></div>
						<div class="circle"></div>
						<div class="circle"></div>
						<div class="circle"></div>
						<div class="circle"></div>
						<div class="circle"></div>
						<div class="circle"></div>
						<div class="circle"></div>
					</div>

					<div class="poster__body-layer-3">
						<div class="circle"></div>
						<div class="circle"></div>
						<div class="circle"></div>
						<div class="circle"></div>
					</div>

					<div class="poster__body-layer-4">
						<div class="circle"></div>
					</div>
				</section>

			</div>
			<!-- .poster__content -->
		</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
 */
 // Colors
$primary-color: #02065D;
$yellow: #FF9A04;
$orange: #FE4612;
$vermilion: #F72F1F;
$red: #E2100F;

// Measurements
$base-unit: 8.3333333333%;
$circle-height: 24%;
$border-width: 4px;

// Animations
$timing: cubic-bezier(0.455,  0.030, 0.515, 0.955);
$duration: 1s;


/**
 * Animations
 */
@keyframes mutateColor-1 {
    0% {
        background-color: $yellow;
    }
    20% {
        background-color: $orange;
    }
    40% {
        background-color: $vermilion;
    }
    80% {
        background-color: $red;
    }
}

@keyframes mutateColor-2 {
    0% {
        background-color: $orange;
    }
    20% {
        background-color: $vermilion;
    }
    40% {
        background-color: $red;
    }
    80% {
        background-color: $yellow;
    }
}

@keyframes mutateColor-3 {
    0% {
        background-color: $vermilion;
    }
    20% {
        background-color: $red;
    }
    40% {
        background-color: $yellow;
    }
    80% {
        background-color: $orange;
    }
}

@keyframes mutateColor-4 {
    0% {
        background-color: $red;
    }
    20% {
        background-color: $yellow;
    }
    40% {
        background-color: $orange;
    }
    80% {
        background-color: $vermilion;
    }
}


/**
 * 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: white;
  box-shadow: 0 1px 4px 2px rgba(#000,.2);
}

.poster__header {
    overflow: hidden;

    h1,
    h2,
    h3 {
        position: absolute;
        font-size: 16px;
        font-weight: normal;
    }

    h1 {
        left: $base-unit*2;
    }

    h2 {
        left: $base-unit*6;
    }

    h3 {
        left: $base-unit*9;
    }
}

.poster__body {
    @include pos(absolute, 25%, 0, auto, 0);
    z-index: 1;
    height: 100%;
    transform: scale(1.1);

    &:before {
        content: "";
        position: absolute;
        top: 36%;
        left: 50%;
        z-index: 5;
        display: block;
        width: 100%;
        height: 3px;
        background-color: $primary-color;
    }
}

.circle {
    position: absolute;
    width: $base-unit*4;
    height: $circle-height;
    background-color: $primary-color;
    border: $border-width solid $primary-color;

    &:before {
        content: "";
        position: absolute;
        z-index: 1;
        width: 100%;
        height: 100%;
        border-radius: 50%;
    }

    &:after {
        @include center();
        content: "";
        z-index: 2;
        width: 35%;
        height: 35%;
        background-color: $primary-color;
        border-radius: 50%;
    }
}

.poster__body-layer-1 .circle {
    z-index: 1;

    &:before {
        animation: mutateColor-1 4s $timing infinite;
        background-color: $yellow;
    }

    &:nth-child(1) {
        left: $base-unit*4;
    }

    &:nth-child(2) {
        top: $circle-height/6;
        left: $base-unit*2;
    }

    &:nth-child(3) {
        top: $circle-height/6;
        left: $base-unit*6;
    }

    &:nth-child(4) {
        top: $circle-height/2;
        left: $base-unit/1.5;
    }

    &:nth-child(5) {
        top: $circle-height/2;
        right: $base-unit/1.5;
    }

    &:nth-child(6) {
        top: $circle-height*1.5;
        left: $base-unit/1.5;
    }

    &:nth-child(7) {
        top: $circle-height*1.5;
        right: $base-unit/1.5;
    }

    &:nth-child(8) {
        //top: $circle-height*1.82;
        top: $circle-height*1.825;
        left: $base-unit*2;
    }

    &:nth-child(9) {
        //top: $circle-height*1.82;
        top: $circle-height*1.825;
        right: $base-unit*2;
    }
}

.poster__body-layer-2 .circle {
    z-index: 2;

    &:before {
        animation: mutateColor-2 4s $timing infinite;
        background-color: $orange;
    }

    &:nth-child(1) {
        top: $circle-height/6;
        left: $base-unit*4;
    }

    &:nth-child(2) {
        top: $circle-height/2;
        left: $base-unit*2;
    }

    &:nth-child(3) {
        top: $circle-height/2;
        right: $base-unit*2;
    }

    &:nth-child(4) {
        top: $circle-height;
        left: $base-unit/1.5;
    }

     &:nth-child(5) {
        top: $circle-height;
        right: $base-unit/1.5;
    }

    &:nth-child(6) {
        top: $circle-height*1.5;
        left: $base-unit*2;
    }

    &:nth-child(7) {
        top: $circle-height*1.5;
        right: $base-unit*2;
    }

    &:nth-child(8) {
        top: $circle-height*1.825;
        left: $base-unit*4;
    }
}

.poster__body-layer-3 .circle {
    z-index: 3;

    &:before {
        animation: mutateColor-3 4s $timing infinite;
        background-color: $vermilion;
    }

    &:nth-child(1) {
        top: $circle-height/2;
        left: $base-unit*4;
    }

    &:nth-child(2) {
        top: $circle-height;
        left: $base-unit*2;
    }

    &:nth-child(3) {
        top: $circle-height;
        right: $base-unit*2;
    }

    &:nth-child(4) {
        top: $circle-height*1.5;
        left: $base-unit*4;
    }
}

.poster__body-layer-4 .circle {
    z-index: 4;

    &:before {
        animation: mutateColor-4 4s $timing infinite;
        background-color: $red;
    }

    top: $circle-height;
    left: $base-unit*4;
}
(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