CSS multiple animation keyframes sequence and delay not working - html

I created 2 keyframes. The 1st keyframe is applied to all elements with class .drop-in. And the 2nd keyframe is specific to an element with class .look-at-me, when the 1st keyframe animation has finished.
The problem is, even though I have added a delay on the 2nd keyframe for the class .look-at-me, all animations are still occurring at the same time instead of applying the delay.
Can someone help me fix this?
Check my work here: Codepen
HTML :
<ul class="box-list">
<li>
<div class="box drop-in">
<h1>The Box</h1>
</div>
</li>
<li>
<div class="box drop-in">
<h1>The Box</h1>
</div>
</li>
<li>
<div class="box drop-in look-at-me">
<h1>The Box</h1>
</div>
</li>
<li>
<div class="box drop-in">
<h1>The Box</h1>
</div>
</li>
</ul>
LESS :
*, *:before, *:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body {
background: #222;
}
.box-list {
list-style: none;
li {
width: 140px;
height: 145px;
display: inline-block;
margin-right: 24px;
position: relative;
&:last-child {
margin-right: 0;
}
.drop-in {
-webkit-animation: drop-in-anim 0.3s forwards;
-moz-animation: drop-in-anim 0.3s forwards;
animation: drop-in-anim 0.3s forwards;
opacity: 0;
}
.look-at-me {
-webkit-animation: drop-in-anim 0.3s forwards, look-at-me-anim 0.5s forwards;
-moz-animation: drop-in-anim 0.3s forwards, look-at-me-anim 0.5s forwards;
animation: drop-in-anim 0.3s forwards, look-at-me-anim 0.5s forwards;
-webkit-animation-delay: 0s, 20s;
-moz-animation-delay: 0s, 20s;
animation-delay: 0s, 20s;
}
&:nth-child(1) {
.drop-in {
-webkit-animation-delay: 0.2s;
-moz-animation-delay: 0.2s;
animation-delay: 0.2s;
}
}
&:nth-child(2) {
.drop-in {
-webkit-animation-delay: 0.3s;
-moz-animation-delay: 0.3s;
animation-delay: 0.3s;
}
}
&:nth-child(3) {
.drop-in {
-webkit-animation-delay: 0.4s;
-moz-animation-delay: 0.4s;
animation-delay: 0.4s;
}
}
&:nth-child(4) {
.drop-in {
-webkit-animation-delay: 0.5s;
-moz-animation-delay: 0.5s;
animation-delay: 0.5s;
}
}
.box {
padding: 6px;
border: 1px solid #333;
background: #fff;
z-index: 5;
text-align: center;
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
&:hover,
&.look-at-me {
-webkit-transform: scale(1.3);
-moz-transform: scale(1.3);
transform: scale(1.3);
}
}
}
}
#-webkit-keyframes drop-in-anim {
0% {
opacity: 0;
position: absolute;
top: 50px;
}
100% {
opacity: 1;
top: 0;
}
}
#-moz-keyframes drop-in-anim {
0% {
opacity: 0;
position: absolute;
top: 50px;
}
100% {
opacity: 1;
top: 0;
}
}
#keyframes drop-in-anim {
0% {
opacity: 0;
position: absolute;
top: 50px;
}
100% {
opacity: 1;
top: 0;
}
}
#-webkit-keyframes look-at-me-anim {
50% { -webkit-transform: scale(1.4); }
75% { -webkit-transform: scale(1.2); }
100% { -webkit-transform: scale(1.3); margin: 0 12px; }
}
#-moz-keyframes look-at-me-anim {
50% { -moz-transform: scale(1.4); }
75% { -moz-transform: scale(1.2); }
100% { -moz-transform: scale(1.3); margin: 0 12px; }
}
#keyframes look-at-me-anim {
50% { transform: scale(1.4); }
75% { transform: scale(1.2); }
100% { transform: scale(1.3); margin: 0 12px; }
}

You are overwriting your delay with this.
&:nth-child(3) {
.drop-in {
-webkit-animation-delay: 0.4s;
-moz-animation-delay: 0.4s;
animation-delay: 0.4s;
}
}
you could also write the delay in shorthand:
.look-at-me {
-webkit-animation:drop-in-anim 0.3s ease-in 0.4s forwards,
look-at-me-anim 0.5s ease-in 1s forwards;
}

Related

increasing the height of particular bar in vertical bar chart

I am using a vertical bar chart from the site::
https://codepen.io/anythinggraphic/pen/xxKpBax
/* Bar Graph Vertical */
.bar-graph .year {
-webkit-animation: fade-in-text 2.2s 0.1s forwards;
-moz-animation: fade-in-text 2.2s 0.1s forwards;
animation: fade-in-text 2.2s 0.1s forwards;
}
.bar-graph-vertical {
margin-top: -109px;
max-width: 680px;
}
.bar-graph-vertical .bar-container {
float: left;
height: 150px;
margin-right: 8px;
position: relative;
text-align: center;
width: 40px;
}
.bar-graph-vertical .bar {
border-radius: 3px;
bottom: 40px;
position: absolute;
width: 40px;
}
.bar-graph-vertical .year {
bottom: 0;
left: 0;
margin: 0 auto;
position: absolute;
right: 0;
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-o-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
}
.bar-graph-two .bar::after {
-webkit-animation: fade-in-text 2.2s 0.1s forwards;
-moz-animation: fade-in-text 2.2s 0.1s forwards;
animation: fade-in-text 2.2s 0.1s forwards;
color: #fff;
content: attr(data-percentage);
font-weight: 700;
left: 0;
margin: 0 auto;
position: absolute;
right: 0;
text-align: left;
top: 24px;
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-o-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
}
.bar-graph-two .bar-one .bar {
background-color: #64b2d1;
-webkit-animation: show-bar-one-vertical 1.2s 0.1s forwards;
-moz-animation: show-bar-one-vertical 1.2s 0.1s forwards;
animation: show-bar-one-vertical 1.2s 0.1s forwards;
}
.bar-graph-two .bar-two .bar {
background-color: #5292ac;
-webkit-animation: show-bar-two-vertical 1.2s 0.2s forwards;
-moz-animation: show-bar-two-vertical 1.2s 0.2s forwards;
animation: show-bar-two-vertical 1.2s 0.2s forwards;
}
.bar-graph-two .bar-three .bar {
background-color: #407286;
-webkit-animation: show-bar-three-vertical 1.2s 0.3s forwards;
-moz-animation: show-bar-three-vertical 1.2s 0.3s forwards;
animation: show-bar-three-vertical 1.2s 0.3s forwards;
}
.bar-graph-two .bar-four .bar {
background-color: #2e515f;
-webkit-animation: show-bar-four-vertical 1.2s 0.4s forwards;
-moz-animation: show-bar-four-vertical 1.2s 0.4s forwards;
animation: show-bar-four-vertical 1.2s 0.4s forwards;
}
I have posted the CSS code block from the site but please refer to the site.
I have to increase the height of a particular bar labelled "2017". I am unable to do that. I tried with inspect element but can't do it. Please can any one help me with this. Thank You!!!
there are two ways:
1)inline css on line 109
100% {
height: 108%;
}
or
2)
<div class="bar" data-percentage="68%" style="height: 120% !important;"></div>
if you use and fill data-percentage on your server side, you could also fill a css var() value meanwhile and use that var to update size and label from CSS.
Writing-mode is also an option to rotate your text.
example
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
--bar: clamp(220px, 40vh, 500px);/* whatever you need here */
min-height:100vh;/*demo purpose */
display:flex;/*demo purpose */
}
body{margin:auto;/*demo purpose */}
ul {
font-size:clamp(10px, 4vmin, 16px);/* whatever you need here */
height: var(--bar);
display: flex;
align-items: end;
padding-top:0.5em;
padding-bottom: 4em;
width:max-content;/*demo purpose */
margin:auto;/*demo purpose */
background:#bee;
border-radius:0.25em;
box-shadow:0 0 5px;/*demo purpose */
transition: 0.2s
}
ul:hover {transform:rotate(-90deg);/*demo purpose */}
li {
width:2em;
writing-mode: vertical-lr;
margin: 0 0.5em;
display: flex;
align-items: center;
animation: show-bar-vertical 1.2s 0.4s forwards;
}
b {
margin-bottom: -4em;
padding:0.5em;
background:#adf
}
span {
padding: 0 0.5em;
flex: 1 1;
border-radius: 0.25em;
margin-bottom: 0.25em;
overflow:hidden;
max-height:0;
box-shadow:1px 1px 2px white,-1px -1px 2px gray;
animation:delay 0.1s 0.25s forwards
}
span:before {
content: attr(data-percentage);
display: inline-block;
color: white;
text-indent: .5em;
height:0;
}
li:nth-child(odd) b {background:#aef;}
li:nth-child(1) span {
background-color: #64b2d1;
}
li:nth-child(2) span {
background-color: #5292ac;
}
li:nth-child(3) span {
background-color: #407286;
}
li:nth-child(4) span {
background-color: #2e515f;
}
li:nth-child(5) span {
background-color: #1e3d49;
}
#keyframes show-bar-vertical {
0% {
height: 0;
}
100% {
height: var(--data-percentage,auto);
}
}
#keyframes delay{
to {max-height:100%;}
}
<!-- example build from a list, structure can be anything else -->
<ul id="bargraph">
<li style="--data-percentage : 40% ">
<span data-percentage=" 40%" ></span>
<b>2020</b>
</li>
<li style="--data-percentage : 55% ">
<span data-percentage=" 55%" ></span>
<b>2019</b>
</li>
<li style="--data-percentage : 100% " >
<span data-percentage=" 100%" ></span>
<b>2018</b>
</li>
<li style="--data-percentage : 82% ">
<span data-percentage=" 82%" ></span>
<b>2017</b>
</li>
<li style="--data-percentage : 25% ">
<span data-percentage=" 25%" ></span>
<b>2016</b>
</li>
</ul>

How to create a snowflake animation scene without using nth-child for each element?

Is there a way to write the CSS code without using all the nth-child() selectors? I want to make the code more scalable in case I want to add more snowflakes in the future.
body {
background-color: red;
}
.snowflake {
color: #fff;
font-size: 1em;
font-family: Arial;
text-shadow: 0 0 1px #000;
}
#-webkit-keyframes snowflakes-fall {
0% {
top: -10%;
}
100% {
top: 100%;
}
}
#-webkit-keyframes snowflakes-shake {
0% {
-webkit-transform: translateX(0px);
transform: translateX(0px);
}
50% {
-webkit-transform: translateX(80px);
transform: translateX(80px);
}
100% {
-webkit-transform: translateX(0px);
transform: translateX(0px);
}
}
#keyframes snowflakes-fall {
0% {
top: -10%;
}
100% {
top: 100%;
}
}
#keyframes snowflakes-shake {
0% {
transform: translateX(0px);
}
50% {
transform: translateX(80px);
}
100% {
transform: translateX(0px);
}
}
.snowflake {
position: fixed;
top: -10%;
z-index: 9999;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
cursor: default;
-webkit-animation-name: snowflakes-fall, snowflakes-shake;
-webkit-animation-duration: 10s, 3s;
-webkit-animation-timing-function: linear, ease-in-out;
-webkit-animation-iteration-count: infinite, infinite;
-webkit-animation-play-state: running, running;
animation-name: snowflakes-fall, snowflakes-shake;
animation-duration: 10s, 3s;
animation-timing-function: linear, ease-in-out;
animation-iteration-count: infinite, infinite;
animation-play-state: running, running;
}
.snowflake:nth-of-type(0) {
left: 1%;
-webkit-animation-delay: 0s, 0s;
animation-delay: 0s, 0s;
}
.snowflake:nth-of-type(1) {
left: 10%;
-webkit-animation-delay: 1s, 1s;
animation-delay: 1s, 1s;
}
.snowflake:nth-of-type(2) {
left: 20%;
-webkit-animation-delay: 6s, 0.5s;
animation-delay: 6s, 0.5s;
}
.snowflake:nth-of-type(3) {
left: 30%;
-webkit-animation-delay: 4s, 2s;
animation-delay: 4s, 2s;
}
.snowflake:nth-of-type(4) {
left: 40%;
-webkit-animation-delay: 2s, 2s;
animation-delay: 2s, 2s;
}
.snowflake:nth-of-type(5) {
left: 50%;
-webkit-animation-delay: 8s, 3s;
animation-delay: 8s, 3s;
}
.snowflake:nth-of-type(6) {
left: 60%;
-webkit-animation-delay: 6s, 2s;
animation-delay: 6s, 2s;
}
.snowflake:nth-of-type(7) {
left: 70%;
-webkit-animation-delay: 2.5s, 1s;
animation-delay: 2.5s, 1s;
}
.snowflake:nth-of-type(8) {
left: 80%;
-webkit-animation-delay: 1s, 0s;
animation-delay: 1s, 0s;
}
.snowflake:nth-of-type(9) {
left: 90%;
-webkit-animation-delay: 3s, 1.5s;
animation-delay: 3s, 1.5s;
}
/* Demo Purpose Only*/
.demo {
font-family: 'Raleway', sans-serif;
color: #fff;
display: block;
margin: 0 auto;
padding: 15px 0;
text-align: center;
}
.demo a {
font-family: 'Raleway', sans-serif;
color: #000;
}
<div class="snowflakes" aria-hidden="true">
<div class="snowflake">❅</div>
<div class="snowflake">❅</div>
<div class="snowflake">❆</div>
<div class="snowflake">❄</div>
<div class="snowflake">❅</div>
<div class="snowflake">❆</div>
<div class="snowflake">❄</div>
<div class="snowflake">❅</div>
<div class="snowflake">❆</div>
<div class="snowflake">❄</div>
</div>
Start by removing all the non needed prefixes and the default values. Then in such situation you can use inline styles combined with CSS variables to add the specific CSS. I have also updated the code a little to use flexbox and get rid of all the left values:
.snowflakes {
display: flex;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #000;
z-index: 9999;
pointer-events:none;
}
.snowflake {
color: #fff;
font-size: 1em;
font-family: Arial;
text-shadow: 0 0 1px #000;
flex: 1;
position: relative;
top: -10%;
animation: snowflakes-fall 10s linear, snowflakes-shake 3s ease-in-out;
animation-delay: var(--d);
animation-iteration-count: infinite;
}
#keyframes snowflakes-fall {
100% {
top: 100%;
}
}
#keyframes snowflakes-shake {
50% {
transform: translateX(80px);
}
}
<div class="snowflakes" aria-hidden="true">
<div class="snowflake" style="--d: 0s, 0s;">❅</div>
<div class="snowflake" style="--d: 1s, 1s;">❅</div>
<div class="snowflake" style="--d: 6s, 0.5s;">❆</div>
<div class="snowflake" style="--d: 4s, 2s;">❄</div>
<div class="snowflake" style="--d: 2s, 2s;">❅</div>
<div class="snowflake" style="--d: 8s, 3s;">❆</div>
<div class="snowflake" style="--d: 6s, 2s;">❄</div>
<div class="snowflake" style="--d: 2.5s, 1s;">❅</div>
<div class="snowflake" style="--d: 1s, 0s;">❆</div>
<div class="snowflake" style="--d: 3s, 1.5s;">❄</div>
</div>

Why does first slideshow image click skip transition and go straight to image?

In the slideshow shown below, there are two images available. Once clicking on a button for the second image after first opening my page, there is a sudden jump to that image with no 5 second transition as expected. Also when doing this, I notice that #slideshowimage-2 is shown in the url (doing this offline) after clicking the button for that image. Here's the code below:
CSS:
.slideshowcontainer {
width:800px;
height:400px;
margin-left:auto;
margin-right:auto;
margin-top:0px;
text-align:center;
overflow:hidden;
position:relative;
top:30px;
border-style:solid;
border-width:10px;
border-color:white;
border-radius:15px;
}
.imagecontainer {
width:1800px;
height:400px;
clear: both;
position:relative;
-webkit-transition:left 3s;
-moz-transition:left 3s;
-o-transition:left 3s;
-ms-transition:left 3s;
transition:left 3s;
animation:scroller 16s infinite;
}
#keyframes scroller {
0% {transform:translateX(0);}
31.25% {transform:translateX(0);}
50% {transform:translateX(-800px);}
81.25% {transform:translateX(-800px);}
100% {transform:translateX(0);}
}
.slideshowimage {
float:left;
margin:0px;
padding:0px;
position:relative;
}
#keyframes change {
0% {
transform: translateX(-800px);
}
100% {
transform: translateX(0);
animation: scroller 16s infinite;
}
}
#keyframes change2 {
0% {
transform: translateX(0);
}
100% {
transform: translateX(-800px);
animation: scroller2 16s infinite;
}
}
#slideshowimage-1:target ~ .imagecontainer {
animation: none;
transform: translateX(0px);
animation: change 3s forwards;
}
#slideshowimage-2:target ~ .imagecontainer {
animation: none;
transform: translateX(-800px);
animation: change2 3s forwards;
}
.buttoncontainer {
position:relative;
top:-20px;
}
.button {
display:inline-block;
height:10px;
width:10px;
border-radius:10px;
background-color:darkgray;
-webkit-transition:background-color 0.25s;
-moz-transition:background-color 0.25s;
-o-transition:background-color 0.25s;
-ms-transition:background-color 0.25s;
transition:background-color 0.25s;
}
.button:hover {
background-color:gray;
}
HTML:
<div class="slideshowcontainer">
<span id="slideshowimage-1"></span>
<span id="slideshowimage-2"></span>
<span id="slideshowimage-3"></span>
<div class="imagecontainer">
<img src="WebServiceSlide.png" class="slideshowimage" style="width:800px;height:400px;">
<img src="es-flag.png" class="slideshowimage" style="width:800px;height:400px;">
</div>
<div class="buttoncontainer">
</div>
</div>
How could I make it so that the transition set upon clicking a button occurs on the first click? Many thanks in advance.
Reason:-
Because the left and translateX both are different. If you apply left:-800px when slide is at translateX(-800px) (2nd slide) then animation will continue at the 2nd part of slideshow. Thats why you are seeing a blank white space(when translateX(-800px) accors when it is already left:-800px).
Solution:-
You either have to use translateX or left. use the same in all the places
Part of code that solved the problem:-
#keyframes change {
0% {
transform: translateX(-800px);
}
100% {
transform: translateX(0);
animation: scroller 16s infinite;
}
}
#keyframes change2 {
0% {
transform: translateX(0);
}
100% {
transform: translateX(-800px);
animation: scroller2 16s infinite;
}
}
#slideshowimage-1:target ~ .imagecontainer {
animation: none;
transform: translateX(0px);
animation: change 3s forwards;
}
#slideshowimage-2:target ~ .imagecontainer {
animation: none;
transform: translateX(-800px);
animation: change2 3s forwards;
}
Explanation:-
This code doesn't do translateX manually. Instead it uses animation to scoll single time by animation: change 3s forwards;
Drawback:-
Once we click on the slide selection button the animation stops. I have even tried it to solve by adding animation in the change keyframes animate end section. But unfortunately it didn't work. So I would suggest an alternate method to overcome the drawback as follows
To overcome the drawback I have added a play button which
will replay the slideshow animation which got paused by the slide
button. (Once we click on play button it takes a little time to slide
as we have given 16s in animation)
DEMO:-
.slideshowcontainer {
width: 800px;
height: 400px;
margin-left: auto;
margin-right: auto;
margin-top: 0px;
text-align: center;
overflow: hidden;
position: relative;
top: 30px;
border-style: solid;
border-width: 10px;
border-color: white;
border-radius: 15px;
}
.imagecontainer {
width: 1800px;
height: 400px;
clear: both;
position: relative;
-webkit-transition: all 3s;
-moz-transition: all 3s;
-o-transition: all 3s;
-ms-transition: all 3s;
transition: all 3s;
transform: translateX(0px);
animation: scroller 16s infinite;
}
#keyframes scroller {
0% {
transform: translateX(0);
}
31.25% {
transform: translateX(0);
}
50% {
transform: translateX(-800px);
}
81.25% {
transform: translateX(-800px);
}
100% {
transform: translateX(0);
}
}
#keyframes scroller2 {
0% {
transform: translateX(-800px);
}
31.25% {
transform: translateX(-800px);
}
50% {
transform: translateX(0);
}
81.25% {
transform: translateX(0);
}
100% {
transform: translateX(-800px);
}
}
#keyframes change {
0% {
transform: translateX(-800px);
}
100% {
transform: translateX(0);
animation: scroller 16s infinite;
}
}
#keyframes change2 {
0% {
transform: translateX(0);
}
100% {
transform: translateX(-800px);
animation: scroller2 16s infinite;
}
}
.slideshowimage {
float: left;
margin: 0px;
padding: 0px;
position: relative;
}
#slideshowimage-1:target ~ .imagecontainer {
animation: none;
transform: translateX(0px);
animation: change 3s forwards;
}
#slideshowimage-2:target ~ .imagecontainer {
animation: none;
transform: translateX(-800px);
animation: change2 3s forwards;
}
#slideshowimage-3:target ~ .imagecontainer {
transform: translateX(0);
animation: scroller 16s infinite;
}
.buttoncontainer {
position: relative;
top: -20px;
}
.button {
display: inline-block;
height: 10px;
width: 10px;
border-radius: 10px;
background-color: darkgray;
-webkit-transition: background-color 0.25s;
-moz-transition: background-color 0.25s;
-o-transition: background-color 0.25s;
-ms-transition: background-color 0.25s;
transition: background-color 0.25s;
}
.button:hover {
background-color: gray;
}
.buttonplay:after {
height: 0;
width: 0;
top: 0;
margin-left: 10px;
position: absolute;
content: ' ';
border-left: solid 13px darkgray;
border-top: solid 8px transparent;
border-bottom: solid 8px transparent;
}
<div class="slideshowcontainer">
<span id="slideshowimage-1"></span>
<span id="slideshowimage-2"></span>
<span id="slideshowimage-3"></span>
<div class="imagecontainer">
<img src="https://placehold.it/800x400" class="slideshowimage" style="width:800px;height:400px;">
<img src="https://placehold.it/900x450" class="slideshowimage" style="width:800px;height:400px;">
</div>
<div class="buttoncontainer">
</div>
</div>

How to use CSS Loader in my website?

I want to use this css loader before full load site.
CSS loader source: http://tobiasahlin.com/spinkit.
On this site no documents or help.
How to use this HTML code in my website?
HTML:
<div class="sk-cube-grid">
<div class="sk-cube sk-cube1"></div>
<div class="sk-cube sk-cube2"></div>
<div class="sk-cube sk-cube3"></div>
<div class="sk-cube sk-cube4"></div>
<div class="sk-cube sk-cube5"></div>
<div class="sk-cube sk-cube6"></div>
<div class="sk-cube sk-cube7"></div>
<div class="sk-cube sk-cube8"></div>
<div class="sk-cube sk-cube9"></div>
</div>
CSS:
.sk-cube-grid {
width: 40px;
height: 40px;
margin: 100px auto;
}
.sk-cube-grid .sk-cube {
width: 33%;
height: 33%;
background-color: #333;
float: left;
-webkit-animation: sk-cubeGridScaleDelay 1.3s infinite ease-in-out;
animation: sk-cubeGridScaleDelay 1.3s infinite ease-in-out;
}
.sk-cube-grid .sk-cube1 {
-webkit-animation-delay: 0.2s;
animation-delay: 0.2s; }
.sk-cube-grid .sk-cube2 {
-webkit-animation-delay: 0.3s;
animation-delay: 0.3s; }
.sk-cube-grid .sk-cube3 {
-webkit-animation-delay: 0.4s;
animation-delay: 0.4s; }
.sk-cube-grid .sk-cube4 {
-webkit-animation-delay: 0.1s;
animation-delay: 0.1s; }
.sk-cube-grid .sk-cube5 {
-webkit-animation-delay: 0.2s;
animation-delay: 0.2s; }
.sk-cube-grid .sk-cube6 {
-webkit-animation-delay: 0.3s;
animation-delay: 0.3s; }
.sk-cube-grid .sk-cube7 {
-webkit-animation-delay: 0s;
animation-delay: 0s; }
.sk-cube-grid .sk-cube8 {
-webkit-animation-delay: 0.1s;
animation-delay: 0.1s; }
.sk-cube-grid .sk-cube9 {
-webkit-animation-delay: 0.2s;
animation-delay: 0.2s; }
#-webkit-keyframes sk-cubeGridScaleDelay {
0%, 70%, 100% {
-webkit-transform: scale3D(1, 1, 1);
transform: scale3D(1, 1, 1);
} 35% {
-webkit-transform: scale3D(0, 0, 1);
transform: scale3D(0, 0, 1);
}
}
#keyframes sk-cubeGridScaleDelay {
0%, 70%, 100% {
-webkit-transform: scale3D(1, 1, 1);
transform: scale3D(1, 1, 1);
} 35% {
-webkit-transform: scale3D(0, 0, 1);
transform: scale3D(0, 0, 1);
}
}
After refresh page, not work this code...
Add the css inline in the head of the document. Then you can either add your css under it or in the footer before the closing body tag (isn't proper HTML but it works fine).
Add a css class for a preloader div and have it position fixed, top, right, bottom, left all as 0 and a high z-index. Place the HTML for the preloader in that div.
Then add your ja files after the css if they r in the footer otherwise add them before the closing body tag anyway.
And then you want some jquery or JavaScript to display none the containing div from above.
HTML:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<html>
<head>
HEAD STUFF
<style>
.sk-cube-grid {
width: 40px;
height: 40px;
margin: 100px auto;
}
.sk-cube-grid .sk-cube {
width: 33%;
height: 33%;
background-color: #333;
float: left;
-webkit-animation: sk-cubeGridScaleDelay 1.3s infinite ease-in-out;
animation: sk-cubeGridScaleDelay 1.3s infinite ease-in-out;
}
.sk-cube-grid .sk-cube1 {
-webkit-animation-delay: 0.2s;
animation-delay: 0.2s;
}
.sk-cube-grid .sk-cube2 {
-webkit-animation-delay: 0.3s;
animation-delay: 0.3s;
}
.sk-cube-grid .sk-cube3 {
-webkit-animation-delay: 0.4s;
animation-delay: 0.4s;
}
.sk-cube-grid .sk-cube4 {
-webkit-animation-delay: 0.1s;
animation-delay: 0.1s;
}
.sk-cube-grid .sk-cube5 {
-webkit-animation-delay: 0.2s;
animation-delay: 0.2s;
}
.sk-cube-grid .sk-cube6 {
-webkit-animation-delay: 0.3s;
animation-delay: 0.3s;
}
.sk-cube-grid .sk-cube7 {
-webkit-animation-delay: 0s;
animation-delay: 0s;
}
.sk-cube-grid .sk-cube8 {
-webkit-animation-delay: 0.1s;
animation-delay: 0.1s;
}
.sk-cube-grid .sk-cube9 {
-webkit-animation-delay: 0.2s;
animation-delay: 0.2s;
}
#-webkit-keyframes sk-cubeGridScaleDelay {
0%, 70%, 100% {
-webkit-transform: scale3D(1, 1, 1);
transform: scale3D(1, 1, 1);
}
35% {
-webkit-transform: scale3D(0, 0, 1);
transform: scale3D(0, 0, 1);
}
}
#keyframes sk-cubeGridScaleDelay {
0%, 70%, 100% {
-webkit-transform: scale3D(1, 1, 1);
transform: scale3D(1, 1, 1);
}
35% {
-webkit-transform: scale3D(0, 0, 1);
transform: scale3D(0, 0, 1);
}
}
div#preloader {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 999;
</style>
</head>
<body>
<div id="preloader">
<div class="sk-cube-grid">
<div class="sk-cube sk-cube1"></div>
<div class="sk-cube sk-cube2"></div>
<div class="sk-cube sk-cube3"></div>
<div class="sk-cube sk-cube4"></div>
<div class="sk-cube sk-cube5"></div>
<div class="sk-cube sk-cube6"></div>
<div class="sk-cube sk-cube7"></div>
<div class="sk-cube sk-cube8"></div>
<div class="sk-cube sk-cube9"></div>
</div>
</div>
HAVE YOUR MAIN BODY HERE
CSS FILE LINKS & JS FILE LINKS GO HERE (YOU NEED JQUERY)
<script>
$("#preloader" ).fadeOut(300);
</script>
</body>
</html>

how to use display:none/block within keyframe animation

I currently have 5 crossfading images with a hover div to appear above the image. I have added a link reference to each image below and set the css to the "a" component in order for the images to pan in and out properly.
.crossfade_container {
display: inline-block;
float: right;
position: relative;
background-color: #f0f0f0;
width: 695px;
height: 350px;
margin-top: 10px;
box-shadow: 2px 2px 2px silver;
}
#crossfade a {
width: 695px;
height: 350px;
position: absolute;
top: 0px;
left: 0px;
color: transparent;
opacity: 0;
z-index: 0;
-webkit-backface-visibility: hidden;
-webkit-animation: imageAnimation 60s linear infinite 0s;
-moz-animation: imageAnimation 60s linear infinite 0s;
-o-animation: imageAnimation 60s linear infinite 0s;
-ms-animation: imageAnimation 60s linear infinite 0s;
animation: imageAnimation 60s linear infinite 0s;
}
#crossfade .caption {
font-size: 30px;
opacity: 0;
position: absolute;
height: 75px;
width: 665px;
bottom: 0px;
left: 0px;
color: white;
background: #00274c;
text-align: left;
padding-top: 10px;
padding-left: 30px;
border-bottom: 1px solid #00274c;
font-weight: bold;
line-height: 25px;
-o-transition: .7s;
-ms-transition: .7s;
-moz-transition: .7s;
-webkit-transition: .7s;
transition: .7s;
}
#crossfade .caption span3 {
font-size: 13px;
}
#crossfade:hover .caption {
cursor: pointer;
opacity: 1.0;
}
#crossfade:hover img {
cursor: pointer;
}
#crossfade a:nth-child(2) {
-webkit-animation-delay: 12s;
-moz-animation-delay: 12s;
-o-animation-delay: 12s;
-ms-animation-delay: 12s;
animation-delay: 12s;
}
#crossfade a:nth-child(3) {
-webkit-animation-delay: 24s;
-moz-animation-delay: 24s;
-o-animation-delay: 24s;
-ms-animation-delay: 24s;
animation-delay: 24s;
}
#crossfade a:nth-child(4) {
-webkit-animation-delay: 36s;
-moz-animation-delay: 36s;
-o-animation-delay: 36s;
-ms-animation-delay: 36s;
animation-delay: 36s;
}
#crossfade a:nth-child(5) {
-webkit-animation-delay: 48s;
-moz-animation-delay: 48s;
-o-animation-delay: 48s;
-ms-animation-delay: 48s;
animation-delay: 48s;
}
#-webkit-keyframes imageAnimation {
5% {
opacity: 1;
-webkit-animation-timing-function: ease-in;
display: none;
}
8% {
opacity: 1;
-webkit-animation-timing-function: ease-out;
display: block;
}
17% {
opacity: 1
display: block;
}
25% {
opacity: 0
display: block;
}
100% {
opacity: 0
display: block;
}
}
#-moz-keyframes imageAnimation {
0% {
opacity: 1;
-moz-animation-timing-function: ease-in;
display: none;
}
8% {
opacity: 1;
-moz-animation-timing-function: ease-out;
display: block;
}
17% {
opacity: 1
display: block;
}
25% {
opacity: 0
display: block;
}
100% {
opacity: 0
display: block;
}
}
#-o-keyframes imageAnimation {
0% {
opacity: 1;
-o-animation-timing-function: ease-in;
display: none;
}
8% {
opacity: 1;
-o-animation-timing-function: ease-out;
display: block;
}
17% {
opacity: 1
display: block;
}
25% {
opacity: 0
display: block;
}
100% {
opacity: 0
display: block;
}
}
#-ms-keyframes imageAnimation {
0% {
opacity: 1;
-ms-animation-timing-function: ease-in;
display: none;
}
8% {
opacity: 1;
-ms-animation-timing-function: ease-out;
}
17% {
opacity: 1
}
25% {
opacity: 0
}
100% {
opacity: 0
}
}
#keyframes imageAnimation {
0% {
opacity: 1;
animation-timing-function: ease-in;
display: none;
}
8% {
opacity: 1;
animation-timing-function: ease-out;
}
17% {
opacity: 1
}
25% {
opacity: 0
}
100% {
opacity: 0
}
}
I am trying to figure out how to insert display: block and display: none within the keyframe animation css to be able to link to the correct website. Each image has a different url associated with it. my method is not working properly.
<div class="crossfade_container">
<div id="crossfade">
<a href="http://espn.com">
<img src="the-schott.png" alt="" />
<div class="caption">PREVIEW:
<br />
<span3>preview addition info</span3>
</div>
</a>
<a href="http://yahoo.com">
<img src="stump.png" alt="" />
<div class="caption">TITLE TWO
<br />
<span3>subtitle two</span3>
</div>
</a>
<a href="http://gmail.com">
<img src="um_huddle1.png" alt="" />
<div class="caption">TITLE ONE
<br />
<span3>subtitle one</span3>
</div>
</a>
<a href="http://hotmail.com">
<img src="osu_crossfade2.png" alt="" />
<div class="caption">Caption Goes Here</div>
</a>
<a href="http://fox.com">
<img src="um_qb1.png" alt="" />
<div class="caption">Caption Goes Here</div>
</a>
I have managed to come up with something using z-index in order to achieve what I want. For each keyframe animation (5), I used the following CSS:
#-webkit-keyframes imageAnimation {
5% {
opacity: 1;
-webkit-animation-timing-function: ease-in;
z-index: 100;
}
8% {
opacity: 1;
-webkit-animation-timing-function: ease-out;
}
17% {
opacity: 1
}
25% {
opacity: 0
}
100% {
opacity: 0
}
}