Skip to content

Instantly share code, notes, and snippets.

@ashlynnpai
Created April 26, 2014 02:52
Show Gist options
  • Save ashlynnpai/11310561 to your computer and use it in GitHub Desktop.
Save ashlynnpai/11310561 to your computer and use it in GitHub Desktop.
A Pen by Ashlynn Pai.
<!DOCTYPE html>
<html>
<head>
<title>Mike the Frogger Toggle</title>
<link href='http://fonts.googleapis.com/css?family=Ubuntu' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" title="no title" charset="utf-8">
</head>
<body>
<div class="one">
<img src="http://imageshack.com/a/img841/2325/mli1.png">
<img src="http://imageshack.com/a/img841/2325/mli1.png">
<img src="http://imageshack.com/a/img841/2325/mli1.png">
</div>
<div class="two">
<img src="http://imageshack.com/a/img843/2024/1qnz.png">
<img src="http://imageshack.com/a/img843/2024/1qnz.png">
</div>
<div class="switch">
<input type="checkbox">
<label><i></i></label>
</div>
<div class="heart">
<img src="http://imageshack.com/a/img842/7602/0axz.png">
</div>
<script src="http://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/app.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>

Mike the Frogger

When you click on Mike the Frog's toggle, his friend comes out of the water. The movement animations cycle at 50 seconds.

I made this for the Treehouse student contest. The "Mike the Frog" logo is the property of Treehouse Island, Inc. and is used here under a fair use claim. The clip art of bugs, flowers and plants belongs to nicubunu.ro and was released into the public domain. I was inspired by the Frogger video game which was developed by Konami Corporation.

I got the code for the basic toggle from http://tympanus.net/codrops/2012/09/13/button-switches-with-checkboxes-and-css3-fanciness/.

A Pen by Ashlynn Pai on CodePen.

License.

$(".switch").click(function() {
$(".heart").toggle(this.checked);
});
body {
max-width: 990px;
margin: 0 auto;
background: url("http://imageshack.com/a/img843/1376/uqdz.png") repeat-x;
-webkit-animation: bg-move 50s infinite;
animation: bg-move 50s infinite;
}
.one {
margin-top: 250px;
margin-left: 50px;
padding: 20px;
}
.two {
padding: 20px; 50px;
margin-left: 250px;
}
.switch input {
position: absolute;
width: 100%;
height: 100%;
z-index: 100;
opacity: 0;
cursor: pointer;
}
.switch {
padding: 20px;
width: 200px;
height: 65px;
position: relative;
margin-left: 200px;
}
.switch label {
display: block;
width: 100%;
height: 100%;
position: relative;
background-image: url(http://imageshack.com/a/img841/2325/mli1.png);
background-repeat: no-repeat;
}
.switch label i {
display: block;
height: 80%;
width: 60%;
position: absolute;
left: 15%;
top: 0;
z-index: 2;
background-image: url(http://imageshack.com/a/img836/6248/2gv8.png);
background-repeat: no-repeat;
}
.switch label i:before {
content: "hip";
position: absolute;
top: 50%;
right: 5%;
margin-top: -12px;
color: #F4FA58;
font-family: 'Ubuntu', 'sans-serif;
font-size: 24px;
font-style: normal;
text-transform: uppercase;
}
.switch input:checked ~ label i {
left: auto;
right: -1%;
}
.switch input:checked ~ label i:before {
content: "HOP";
color: #F4FA58;
right: 105%
}
.heart {
margin-left: 280px;
display: none;
}
@keyframes bg-move{
0% {background-position: 100% 0px;}
100% {background-position: -350% 0px;}
}
@-webkit-keyframes bg-move{
0% {background-position: 100% 0px;}
100% {background-position: -350% 0px;}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment