<div class="wrapper">
<header>
<h1 class="title">Responsive Storytelling</h1>
<h2 class="subtitle">Resize the browser window slowly. <br><small>DESKTOP ONLY. Make sure to go below 500px and above 2000px.</small></h2>
</header>
<div class="heart">
<svg version="1.1" class="heart__left" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 248.5 430" enable-background="new 0 0 248.5 430" xml:space="preserve">
<path d="M248.5,60.5c0,0-37-60.5-130.5-60.5S0,79.5,0,126s31,124,248.5,304L227,366.7l21.5-47.7L209,245.3l39.5-56.8
L219,128.7L248.5,60.5z"/>
</svg>
<svg class="heart__right" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="209 0 287 430" enable-background="new 209 0 287 430" xml:space="preserve">
<path d="M247.5,60.5c0,0,37-60.5,130.5-60.5s118,79.5,118,126s-31,124-248.5,304L227,366.7l20.5-47.7L209,245.3
l38.5-56.8L219,128.7L247.5,60.5z"/>
</svg>
</div>
<div class="smiley">
<div class="smiley__face">
<div class="smiley__eye--left"></div>
<div class="smiley__eye--right"></div>
<div class="smiley__tears">
<div class="tear tear1"></div>
<div class="tear tear2"></div>
<div class="tear tear3"></div>
<div class="tear tear4"></div>
<div class="tear tear5"></div>
<div class="tear tear6"></div>
<div class="tear tear7"></div>
<div class="tear tear8"></div>
<div class="tear tear9"></div>
<div class="tear tear10"></div>
<div class="tear tear11"></div>
<div class="tear tear12"></div>
<div class="tear tear13"></div>
<div class="tear tear14"></div>
<div class="tear tear15"></div>
<div class="tear tear16"></div>
<div class="tear tear17"></div>
<div class="tear tear18"></div>
<div class="tear tear19"></div>
<div class="tear tear20"></div>
<div class="tear tear21"></div>
<div class="tear tear22"></div>
<div class="tear tear23"></div>
<div class="tear tear24"></div>
<div class="tear tear25"></div>
<div class="tear tear26"></div>
<div class="tear tear27"></div>
<div class="tear tear28"></div>
<div class="tear tear29"></div>
<div class="tear tear30"></div>
<div class="tear tear31"></div>
<div class="tear tear32"></div>
<div class="tear tear33"></div>
<div class="tear tear34"></div>
<div class="tear tear35"></div>
<div class="tear tear36"></div>
<div class="tear tear37"></div>
<div class="tear tear38"></div>
<div class="tear tear39"></div>
<div class="tear tear40"></div>
<div class="tear tear41"></div>
<div class="tear tear42"></div>
<div class="tear tear43"></div>
<div class="tear tear44"></div>
<div class="tear tear45"></div>
<div class="tear tear46"></div>
<div class="tear tear47"></div>
<div class="tear tear48"></div>
<div class="tear tear49"></div>
<div class="tear tear50"></div>
</div>
<div class="smiley__mouth"></div>
</div>
<div class="smiley__speech">
<p id="js-speech"> </p>
</div>
</div>
</div>
// ============ BASE ============ //
body {
overflow: hidden; // to prevent scrollbar
background-color: #f1f1f1;
}
.wrapper {
height: 80vh;
width: calc(100vw - 20px);
margin: 10vh 10px 0;
font-family: 'Roboto Slab', serif;
}
// ============ HEADER ============ //
.title {
font-weight: 400;
font-size: 2em;
line-height: 1.2;
margin: 0.25em auto;
text-align: center;
width: 90%;
}
.subtitle {
font-weight: 300;
font-size: 1.5em;
line-height: 1.2;
margin: 0.25em auto 2em;
text-align: center;
width: 90%;
small {
font-size: 50%;
color: #bbb;
}
}
// ============ HEART ============ //
.heart {
position: relative;
&__left path,
&__right path {
fill: #BE1E2D;
}
&__left {
width: 248.5px;
position: absolute;
left: 0;
//margin-top: 50px;
@media screen and (max-width: 515px) {
width: 50.2%;
}
}
&__right {
width: 287px;
position: absolute;
right: 0;
//margin-top: 50px;
@media screen and (max-width: 515px) {
width: 58%;
}
}
}
// ============ SMILEY ============ //
.smiley {
width: 90vw;
left: 5vw;
height: 430px;
display: flex;
flex-flow: column nowrap;
align-items: center;
justify-content: center;
z-index:-1;
position: absolute;
&__face {
background-color: #ffc40f;
background: radial-gradient(#ffc40f 45%, #F5AB35 85%);
height: 100px;
width: 100px;
border-radius: 50%;
position: relative;
}
&__eye--left {
@extend %eye;
@extend %eye--left;
}
&__eye--right {
@extend %eye;
@extend %eye--right;
}
&__mouth {
@extend %mouth;
}
&__speech {
font-weight: 300;
text-align: center;
}
}
// ============ EYES ============ //
%eye {
height: 10px;
width: 10px;
background-color: black;
border-radius: 50%;
position: absolute;
top: 35px;
transition: all 0.15s ease-out;
&--left {
left: 30px;
// LOOK LEFT
@media screen and (min-width: 1101px) and (max-width: 1200px) {
top: 30px;
left: 20px;
}
// LOOK RIGHT
@media screen and (min-width: 1201px) and (max-width: 1300px) {
top: 35px;
left: 50px;
}
// CLOSED
@media screen and (min-width: 1340px) and (max-width: 1350px) {
height: 3px;
width: 12px;
}
@media screen and (min-width: 1390px) and (max-width: 1400px) {
height: 3px;
width: 12px;
}
// SHOCK
@media screen and (min-width: 1451px) and (max-width: 1650px) {
height: 13px;
width: 13px;
}
// CRYING
@media screen and (min-width: 1651px) {
height: 3px;
width: 15px;
transform: rotate(10deg);
}
}
&--right {
right: 30px;
// LOOK LEFT
@media screen and (min-width: 1101px) and (max-width: 1200px) {
top: 35px;
right: 50px;
}
// LOOK RIGHT
@media screen and (min-width: 1201px) and (max-width: 1300px) {
top: 30px;
right: 20px;
}
// CLOSED
@media screen and (min-width: 1340px) and (max-width: 1350px) {
height: 3px;
width: 12px;
}
@media screen and (min-width: 1390px) and (max-width: 1400px) {
height: 3px;
width: 12px;
}
// SHOCK
@media screen and (min-width: 1451px) and (max-width: 1650px) {
height: 13px;
width: 13px;
}
// CRYING
@media screen and (min-width: 1651px) {
height: 3px;
width: 15px;
transform: rotate(-10deg);
}
}
}
// ============ MOUTH ============ //
%mouth {
width: 40px;
position: absolute;
bottom: 25px;
left: 30px;
border-bottom: 3px solid black;
border-radius: 0 0 50% 50%;
@media screen and (min-width: 850px) {
transition: all 0.15s ease-out;
border-radius: 50%;
}
// GRIN
@media screen and (max-width: 800px) {
height: 15px;
background-color: #000;
bottom: 20px;
width: 30px;
left: 35px;
&:before {
content: '';
height: 0;
width: 0;
position: absolute;
border-right: 10px solid black;
border-bottom: 12px solid transparent;
top: 0;
left: -9px;
}
&:after {
content: '';
height: 0;
width: 0;
position: absolute;
border-left: 10px solid black;
border-bottom: 12px solid transparent;
top: 0;
right: -9px;
}
}
// SMILE
@media screen and (min-width: 801px) and (max-width: 1000px) {
height: 15px;
}
// LOOK LEFT
@media screen and (min-width: 1100px) and (max-width: 1200px) {
left: 20px;
transform: rotate(10deg);
width: 30px;
}
// LOOK RIGHT
@media screen and (min-width: 1201px) and (max-width: 1300px) {
left: 50px;
transform: rotate(-10deg);
width: 30px;
}
// OPEN
@media screen and (min-width: 1401px) {
border-radius: 50%;
width: 20px;
height: 20px;
left: 40px;
bottom: 20px;
background-color: #000;
}
@media screen and (min-width: 2001px) {
width: 30px;
height: 25px;
left: 35px;
}
}
// ============ TEARS ============ //
.tear {
height: 8px;
width: 8px;
background-color: rgba(25, 181, 254, 0.75);
position: absolute;
top: 45px;
border-radius: 50%;
opacity: 0;
z-index: 100;
&:before {
content: '';
height: 0;
width: 0;
border-bottom: 10px solid rgba(25, 181, 254, 0.75);
border-left: 4px solid transparent;
position: absolute;
top: -6px;
left: 0px;
}
&:after {
content: '';
height: 0;
width: 0;
border-bottom: 10px solid rgba(25, 181, 254, 0.75);
border-right: 4px solid transparent;
position: absolute;
top: -6px;
right: 0px;
}
// CRY
@for $i from 1 through 3 {
&#{$i} {
@media screen and (min-width: 1700px) {
left: #{random(15) + 20}px;
animation: cry #{random(4)/2}s #{random(5)/10}s infinite;
}
}
}
@for $i from 4 through 6 {
&#{$i} {
@media screen and (min-width: 1700px) {
left: #{random(15) + 55}px;
animation: cry #{random(6)/2}s #{random(5)/10}s infinite;
}
}
}
// CRY HARDER
@for $i from 7 through 13 {
&#{$i} {
@media screen and (min-width: 1801px) {
left: #{random(15) + 20}px;
animation: cryharder #{random(4)/2}s #{random(5)/10}s infinite;
}
}
}
@for $i from 14 through 19 {
&#{$i} {
@media screen and (min-width: 1801px) {
left: #{random(15) + 55}px;
animation: cryharder #{random(6)/2}s #{random(5)/10}s infinite;
}
}
}
// CRY HARDEST
@for $i from 21 through 35 {
&#{$i} {
@media screen and (min-width: 2001px) {
left: #{random(15) + 20}px;
animation: cryhardest #{random(4)/2}s #{random(5)/10}s infinite;
}
}
}
@for $i from 36 through 50 {
&#{$i} {
@media screen and (min-width: 2001px) {
left: #{random(15) + 55}px;
animation: cryhardest #{random(4)/2}s #{random(5)/10}s infinite;
}
}
}
}
@keyframes cry {
0% {
opacity: 0;
}
10% {
transform: translateY(0);
opacity: 1;
}
100% {
transform: translateY(60px);
opacity: 0;
}
}
@keyframes cryharder {
0% {
opacity: 0;
}
10% {
transform: translateY(0);
opacity: 1;
}
100% {
transform: translateY(150px);
opacity: 0;
}
}
@keyframes cryhardest {
0% {
opacity: 0;
}
10% {
transform: translateY(0);
opacity: 1;
}
100% {
transform: translateY(400px);
opacity: 0;
}
}
View Compiled
jQuery(function($) {
// starting dimensions
var $window = $(window),
startingSize = $window.width();
// ending dimensions
$window.resize(function(e) {
var endingSize = $window.width();
// -------- MAKING WINDOW BIGGER -------- //
if ((endingSize > startingSize) & (endingSize < 980)) {
$("#js-speech").text("Hello!");
}
else if ((endingSize > startingSize) & (endingSize > 981) & (endingSize < 1325)) {
$("#js-speech").text("Um");
}
else if ((endingSize > startingSize) & (endingSize > 1326) & (endingSize < 1400)) {
$("#js-speech").text("Wait a minute!");
}
else if ((endingSize > startingSize) & (endingSize > 1401) & (endingSize < 1450)) {
$("#js-speech").text("*gasp*");
}
else if ((endingSize > startingSize) & (endingSize > 1451) & (endingSize < 1650)) {
$("#js-speech").text("No!");
}
else if ((endingSize > startingSize) & (endingSize > 1651) & (endingSize < 2000)) {
$("#js-speech").text("wwwaaahhhh");
}
else if ((endingSize > startingSize) & (endingSize > 2001)) {
$("#js-speech").text("WWWWWWAAAAAAHHHHHHHHH");
}
// -------- MAKING WINDOW SMALLER -------- //
else if ((endingSize < startingSize) & (endingSize < 800)) {
$("#js-speech").text("♥♡♥");
}
else if ((endingSize < startingSize) & (endingSize > 801) & (endingSize < 1000)) {
$("#js-speech").text("Hey!");
}
else if ((endingSize < startingSize) & (endingSize > 1001) & (endingSize < 1340)) {
$("#js-speech").text("Look");
}
else if ((endingSize < startingSize) & (endingSize > 1001) & (endingSize < 1340)) {
$("#js-speech").text("Look");
}
else if ((endingSize < startingSize) & (endingSize > 1341) & (endingSize < 1650)) {
$("#js-speech").text("*sniff sniff*");
}
else if ((endingSize < startingSize) & (endingSize > 1651) & (endingSize < 2000)) {
$("#js-speech").text("wwwaaahhhh");
}
else if ((endingSize < startingSize) & (endingSize > 2001)) {
$("#js-speech").text("WWWWWWAAAAAAHHHHHHHHH");
}
else {
$("#js-speech").html(" ");
}
// Store the new dimensions
startingSize = endingSize;
});
});