HTML
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type='text/javascript' src='file:///C:/Users/ADMIN/Desktop/Cancepto/loading-icon-while-image-loading/loadImg.js'></script>
<script>
$(function(){
$('img').imgPreload()
})
</script>
<body>
<div> <img src="https://s-media-cache-ak0.pinimg.com/originals/79/07/bb/7907bb62e5e2d77255b4fe10770fae41.gif" width="350px" height="400px"style="border-style: none" color="#000"/></div>
<h1>Basketball Animation</h1>
<ul>
<li>
<input type="checkbox" checked>
<i></i>
<h2>About</h2>
<p>Basket Ball </p>
</li>
<li>
<input type="checkbox" checked>
<i></i>
<h2>Hello</h2>
<p>Ipsoum </p>
</li>
</ul>
</body>
CSS
.transition, p, ul li i:before, ul li i:after {
transition: all 0.25s ease-in-out;
}
.images ul li img {
width: 400px;
height: 266px;
}
.images ul li {
display: inline-block;
}
.flipIn, h1, ul li {
animation: flipdown 0.5s ease both;
}
.no-select, h2 {
-webkit-tap-highlight-color: transparent;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
html {
width: 100%;
height: 100%;
perspective: 900;
overflow-y: scroll;
background-color: #321C34;
font-family: "Titillium Web", sans-serif;
color: rgba(48, 69, 92, 0.8);
}
body {
min-height: 0;
display: inline-block;
position: relative;
left: 50%;
margin: -5px 0;
transform: translate(-50%, 0);
background-color: #321C34;
max-width: 450px;
padding: 30px;
}
@media (max-width: 550px) {
body {
box-sizing: border-box;
transform: translate(0, 0);
max-width: 100%;
min-height: 100%;
margin: 0;
left: 0;
}
}
h1, h2 {
color: #fff;
}
h1 {
text-transform: uppercase;
font-size: 36px;
line-height: 42px;
letter-spacing: 3px;
font-weight: 100;
}
h2 {
font-size: 26px;
line-height: 34px;
font-weight: 300;
letter-spacing: 1px;
display: block;
background-color:transparent;
margin: 0;
cursor: pointer;
}
p {
color: #fff;
font-size: 17px;
line-height: 26px;
letter-spacing: 1px;
position: relative;
overflow: hidden;
max-height: 800px;
opacity: 1;
transform: translate(0, 0);
margin-top: 14px;
z-index: 2;
}
ul {
list-style: none;
perspective: 900;
padding: 0;
margin: 0;
}
ul li {
position: relative;
padding: 0;
margin: 0;
padding-bottom: 4px;
padding-top: 18px;
border-top: 1px dotted #321C34 ;
}
ul li:nth-of-type(1) {
animation-delay: 0.5s;
}
ul li:nth-of-type(2) {
animation-delay: 0.75s;
}
ul li:nth-of-type(3) {
animation-delay: 1s;
}
ul li:last-of-type {
padding-bottom: 0;
}
ul li i {
position: absolute;
transform: translate(-6px, 0);
margin-top: 16px;
right: 0;
}
ul li i:before, ul li i:after {
content: "";
position: absolute;
background-color: #fff;
width: 3px;
height: 9px;
}
ul li i:before {
transform: translate(-2px, 0) rotate(45deg);
}
ul li i:after {
transform: translate(2px, 0) rotate(-45deg);
}
ul li input[type=checkbox] {
position: absolute;
cursor: pointer;
width: 100%;
height: 100%;
z-index: 1;
opacity: 0;
}
ul li input[type=checkbox]:checked ~ p {
margin-top: 0;
max-height: 0;
opacity: 0;
transform: translate(0, 50%);
}
ul li input[type=checkbox]:checked ~ i:before {
transform: translate(2px, 0) rotate(45deg);
}
ul li input[type=checkbox]:checked ~ i:after {
transform: translate(-2px, 0) rotate(-45deg);
}
@keyframes flipdown {
0% {
opacity: 0;
transform-origin: top center;
transform: rotateX(-90deg);
}
5% {
opacity: 1;
}
80% {
transform: rotateX(8deg);
}
83% {
transform: rotateX(6deg);
}
92% {
transform: rotateX(-3deg);
}
100% {
transform-origin: top center;
transform: rotateX(0deg);
}
}
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
background: #321C34;
}
::-webkit-scrollbar-thumb {
background: #321C34;
}
::-webkit-scrollbar-thumb:hover {
background: #fff;
}
JAVASCRIPT
(function() {
(function($) {
return $.fn.imgPreload = function(options) {
var delay_completion, i, image_stack, placeholder_stack, replace, settings, spinner_stack, src, x, _i, _len;
settings = {
fake_delay: 10,
animation_duration: 1000,
spinner_src: 'spinner.gif'
};
if (options) {
$.extend(settings, options);
}
image_stack = [];
placeholder_stack = [];
spinner_stack = [];
window.delay_completed = false;
delay_completion = function() {
var x, _i, _len, _results;
window.delay_completed = true;
_results = [];
for (_i = 0, _len = image_stack.length; _i < _len; _i++) {
x = image_stack[_i];
_results.push($(x).attr('data-load-after-delay') === 'true' ? (replace(x), $(x).removeAttr('data-load-after-delay')) : void 0);
}
return _results;
};
setTimeout(delay_completion, settings.fake_delay);
this.each(function() {
var $image, $placeholder, $spinner_img, offset_left, offset_top;
$image = $(this);
offset_top = $image.offset().top;
offset_left = $image.offset().left;
$spinner_img = $('<img>');
$placeholder = $('<img>').attr({
src: 'http://personalauspolen.eu/wp-content/uploads/2012/12/widescreen-grass-dew-best-wallpaper-of-hd.jpg'
});
$placeholder.attr({
width: $image.attr('1400')
});
$placeholder.attr({
height: $image.attr('800')
});
spinner_stack.push($spinner_img);
placeholder_stack.push($placeholder);
image_stack.push($image.replaceWith($placeholder));
$('body').append($spinner_img);
$spinner_img.css({
position: 'absolute'
});
$spinner_img.css('z-index', 9999);
$spinner_img.load(function() {
$(this).css({
left: (offset_left + $placeholder.width() / 2) - $(this).width() / 2
});
return $(this).css({
top: (offset_top + $placeholder.height() / 2) - $(this).height() / 2
});
});
return $spinner_img.attr({
src: settings.spinner_src
});
});
i = 0;
for (_i = 0, _len = image_stack.length; _i < _len; _i++) {
x = image_stack[_i];
x.attr({
no: i++
});
src = x.attr('src');
x.attr({
src: ''
});
x.load(function() {
if (window.delay_completed) {
return replace(this);
} else {
return $(this).attr('data-load-after-delay', true);
}
});
x.attr({
src: src
});
}
replace = function(image) {
var $image, no_;
$image = $(image);
no_ = $image.attr('no');
placeholder_stack[no_].replaceWith($image);
spinner_stack[no_].fadeOut(settings.animation_duration / 2, function() {
return $(this).remove();
});
return $image.fadeOut(0).fadeIn(settings.animation_duration);
};
return this;
};
})(jQuery);
}).call(this);