Skip to content

Instantly share code, notes, and snippets.

Created July 26, 2012 10:58
Show Gist options
  • Save anonymous/3181500 to your computer and use it in GitHub Desktop.
Save anonymous/3181500 to your computer and use it in GitHub Desktop.
A web page created at CodePen.io.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>CSS/JS Circle Splash &middot; CodePen</title>
<!--
Copyright (c) 2012 Steve Belovarich, http://codepen.io/steveblue
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->
<style>
/* Circle Splash
Author: Steve Belovarich
Site: stephenbelovarich.com
Description: Series of circles fade in left to right. CSS styles the basic formatting for each circle, while JS generates the circles and thier color, position and fadeIn timing.
*/
#container {
width: 100%;
height: 100%;
position:absolute;
top:0; left:0%;
}
.circle {
position:absolute;
top: 12%;
width: 240px;
height: 240px;
border-radius: 50%; /* makes the div a circle */
opacity: 0.3;
}
</style>
<style>
#codepen-footer, #codepen-footer * {
-webkit-box-sizing: border-box !important;
-moz-box-sizing: border-box !important;
box-sizing: border-box !important;
}
#codepen-footer {
display: block !important;
position: fixed !important;
bottom: 0 !important;
left: 0 !important;
width: 100% !important;
padding: 0 10px !important;
margin: 0 !important;
height: 30px !important;
line-height: 30px !important;
font-size: 12px !important;
color: #eeeeee !important;
background-color: #505050 !important;
text-align: left !important;
background: -webkit-linear-gradient(top, #505050, #383838) !important;
background: -moz-linear-gradient(top, #505050, #383838) !important;
background: -ms-linear-gradient(top, #505050, #383838) !important;
background: -o-linear-gradient(top, #505050, #383838) !important;
border-top: 1px solid black !important;
border-bottom: 1px solid black !important;
border-radius: 0 !important;
border-image: none !important;
box-shadow: inset 0 1px 0 #6e6e6e, 0 2px 2px rgba(0, 0, 0, 0.4) !important;
z-index: 300 !important;
font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, sans-serif !important;
letter-spacing: 0 !important;
word-spacing: normal !important;
word-spacing: 0 !important;
-webkit-transform: none !important;
-moz-transform: none !important;
-ms-transform: none !important;
-o-transform: none !important;
transform: none !important;
}
#codepen-footer a {
color: #a7a7a7 !important;
text-decoration: none !important;
text-shadow: none !important;
border: 0 !important;
}
#codepen-footer a:hover {
color: white !important;
}
</style>
<script>
// Kill alerts, confirmations and prompts
// window.alert = function(){}; we're going to allow alerts for now
window.confirm = function(){};
window.prompt = function(){};
window.open = function(){};
window.print = function(){};
</script>
<script src="http://codepen.io/javascripts/libs/prefixfree.min.js"></script>
</head>
<body>
<div id="container"></div>
<!-- Refresh page if it doesn't work, seems to be a bug with codepen -->
<!--
The JS generates the following HTML inside the Container:
(one circle separated from the bunch for demonstration)
<div class="circle" style="left: 1435.8974358974358px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 168, 0); display: none; background-position: initial initial; background-repeat: initial initial; "></div>
<div class="circle" style="left: 1376.068376068376px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 161, 0); display: block; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 1316.2393162393162px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 154, 0); display: block; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 1256.4102564102564px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 147, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 1196.5811965811965px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 140, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 1136.7521367521367px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 133, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 1076.923076923077px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 126, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 1017.094017094017px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 119, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 957.2649572649572px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 112, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 897.4358974358973px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 105, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 837.6068376068375px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 98, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 777.7777777777777px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 91, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 717.9487179487179px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 84, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 658.1196581196581px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 77, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 598.2905982905983px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 70, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 538.4615384615385px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 63, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 478.6324786324786px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 56, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 418.80341880341877px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 49, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 358.97435897435895px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 42, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 299.14529914529913px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 35, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 239.31623931623932px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 28, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 179.4871794871795px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 21, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 119.65811965811966px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 14, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 59.82905982905983px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 7, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 0px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 0, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div>
-->
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="http://codepen.io/javascripts/libs/modernizr.js"></script>
<script src="http://ricostacruz.com/jquery.transit/jquery.transit.min.js"></script>
<script>
(function() {
/* Circle Splash v1.2
Author: Steve Belovarich
Site: stephenbelovarich.com
Description: Series of circles fade in left to right. CSS styles the basic formatting for each circle, while JS generates the circles and thier color, position and fadeIn timing.
Example demonstrates the following topics:
jQuery variable creation, programmatic object creation, binding mouseevents to objects, appending elements to the DOM
v1.1 Added MouseEvents
v1.2 Added jQuery Transit for some extra flair
*/
var circle = {}; // creates the circle object
var circleAmt = 24; // number of circles
// init position, color, frame number for fadeIn()
var pos = 0;
var red = 255, green = 0, blue = 0;
var frame = 0;
var $currCirc; // create current Circle variable for jQuery
function makeCircles() { // this function creates each circle and appends it to the container element
for(i=0;i<=circleAmt;i++) { // loops through all circle objects
circle[i]= $('<div />', {
class: 'circle',
style: 'left:'+ pos + 'px; background:rgb('+ red +','+ green +','+ blue +');',
mouseover: function(e){
e.preventDefault();
$(this).transition({opacity:.7},500);
// do something while mouseover
},
mouseout: function(e){
e.preventDefault();
$(this).transition({opacity:.3},500);
// do something while mouseout
},
}); // end circle creation
$('#container').prepend(circle[i].append()); // adds circle to DOM
$currCirc = circle[i]; // create jQuery var to hide() the circle
$currCirc.css({opacity:.3});
// update variables on each loop iteration
pos += (window.innerWidth / (circleAmt * 1.17));
red -= 0;
green += 7;
blue -= 0;
} // end for loop
} // end makeCircles()
function animateCircles() { // function that fades the circles
setTimeout(function () { // call a 3s setTimeout when the loop is called
$currCirc = circle[frame];
//$currCirc.fadeIn();
$currCirc.transition({opacity:.7},50, function() { $(this).transition({ opacity: .3 },600); });
frame++; // increment the counter
if (frame < circleAmt) { // if the counter < circleAmt, call the loop function
animateCircles(); // .. again which will trigger another
} // .. setTimeout()
}, 50)
}; // end animateCircles()
// call both of these in (document).ready in implementation
makeCircles();
animateCircles();
})();
</script>
<div id="codepen-footer">
<a style="color: #f73535 !important;" href="https://codepen.wufoo.com/forms/m7x3r3/def/field14=" onclick="window.open(this.href, null, 'height=517, width=680, toolbar=0, location=0, status=1, scrollbars=1, resizable=1'); return false">Report Abuse</a>
&nbsp;
<a href="/steveblue/pen/hHxag" target="_blank">Edit this Pen</a>
</div>
</body>
</html>
/* Circle Splash v1.2
Author: Steve Belovarich
Site: stephenbelovarich.com
Description: Series of circles fade in left to right. CSS styles the basic formatting for each circle, while JS generates the circles and thier color, position and fadeIn timing.
Example demonstrates the following topics:
jQuery variable creation, programmatic object creation, binding mouseevents to objects, appending elements to the DOM
v1.1 Added MouseEvents
v1.2 Added jQuery Transit for some extra flair
*/
var circle = {}; // creates the circle object
var circleAmt = 24; // number of circles
// init position, color, frame number for fadeIn()
var pos = 0;
var red = 255, green = 0, blue = 0;
var frame = 0;
var $currCirc; // create current Circle variable for jQuery
function makeCircles() { // this function creates each circle and appends it to the container element
for(i=0;i<=circleAmt;i++) { // loops through all circle objects
circle[i]= $('<div />', {
class: 'circle',
style: 'left:'+ pos + 'px; background:rgb('+ red +','+ green +','+ blue +');',
mouseover: function(e){
e.preventDefault();
$(this).transition({opacity:.7},500);
// do something while mouseover
},
mouseout: function(e){
e.preventDefault();
$(this).transition({opacity:.3},500);
// do something while mouseout
},
}); // end circle creation
$('#container').prepend(circle[i].append()); // adds circle to DOM
$currCirc = circle[i]; // create jQuery var to hide() the circle
$currCirc.css({opacity:.3});
// update variables on each loop iteration
pos += (window.innerWidth / (circleAmt * 1.17));
red -= 0;
green += 7;
blue -= 0;
} // end for loop
} // end makeCircles()
function animateCircles() { // function that fades the circles
setTimeout(function () { // call a 3s setTimeout when the loop is called
$currCirc = circle[frame];
//$currCirc.fadeIn();
$currCirc.transition({opacity:.7},50, function() { $(this).transition({ opacity: .3 },600); });
frame++; // increment the counter
if (frame < circleAmt) { // if the counter < circleAmt, call the loop function
animateCircles(); // .. again which will trigger another
} // .. setTimeout()
}, 50)
}; // end animateCircles()
// call both of these in (document).ready in implementation
makeCircles();
animateCircles();
<div id="container"></div>
<!-- Refresh page if it doesn't work, seems to be a bug with codepen -->
<!--
The JS generates the following HTML inside the Container:
(one circle separated from the bunch for demonstration)
<div class="circle" style="left: 1435.8974358974358px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 168, 0); display: none; background-position: initial initial; background-repeat: initial initial; "></div>
<div class="circle" style="left: 1376.068376068376px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 161, 0); display: block; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 1316.2393162393162px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 154, 0); display: block; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 1256.4102564102564px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 147, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 1196.5811965811965px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 140, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 1136.7521367521367px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 133, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 1076.923076923077px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 126, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 1017.094017094017px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 119, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 957.2649572649572px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 112, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 897.4358974358973px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 105, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 837.6068376068375px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 98, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 777.7777777777777px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 91, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 717.9487179487179px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 84, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 658.1196581196581px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 77, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 598.2905982905983px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 70, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 538.4615384615385px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 63, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 478.6324786324786px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 56, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 418.80341880341877px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 49, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 358.97435897435895px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 42, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 299.14529914529913px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 35, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 239.31623931623932px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 28, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 179.4871794871795px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 21, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 119.65811965811966px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 14, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 59.82905982905983px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 7, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div><div class="circle" style="left: 0px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 0, 0); display: block; opacity: 0.3; background-position: initial initial; background-repeat: initial initial; "></div>
-->
/* Circle Splash
Author: Steve Belovarich
Site: stephenbelovarich.com
Description: Series of circles fade in left to right. CSS styles the basic formatting for each circle, while JS generates the circles and thier color, position and fadeIn timing.
*/
#container {
width: 100%;
height: 100%;
position:absolute;
top:0; left:0%;
}
.circle {
position:absolute;
top: 12%;
width: 240px;
height: 240px;
border-radius: 50%; /* makes the div a circle */
opacity: 0.3;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment