CSS3 Photo Gallery Transition Effect - html

I'm trying to create a graceful transition between the images within my photo gallery without using ":hover" or an once of Javascript. (I'm still open minded to HTML5)
The animation, this slideshow, should begin on page load, no user interaction needed. However my CSS isn't properly timed. Ideally, every 6 seconds, the current image begins to fade out just as the next image begins to fade in. The animation should loop infinitely after the last image.
I'm using a delay between the images in an attempt to stagger the animations, but the images overlap each other far too much. I seem to have misunderstood a number of things. My Css is below:
#imgContainer {
height: 205px;
position: relative;
width: 300px;
}
#imgContainer img {
-moz-animation-duration: 12s;
-moz-animation-iteration-count: infinite;
-moz-animation-name: FadeInOut;
-moz-animation-timing-function: ease-in-out;
left: 0;
position: absolute;
}
#imgContainer img:nth-of-type(1) {
-moz-animation-delay: 0s;
}
#imgContainer img:nth-of-type(2) {
-moz-animation-delay: 6s;
}
#imgContainer img:nth-of-type(3) {
-moz-animation-delay: 12s;
}
#-moz-keyframes FadeInOut {
0% {
opacity:0;
}
100% {
opacity:1;
}
}
I'm really new to css3, so any kind of assistance would be greatly appreciated.

Success!
I discovered if I apply an animation to each of my images within the slideshow, rather than being delayed, I could achieve the effect I desired. Basically the animations would run sequentially in an infinite loop, and rather than use a single keyframe, each has their own.
I wanted the slideshow to progress at 15s intervals. So to accomplish this I set the duration of the entire animation to 45s. The keyframes gradually adjust the opacity of the images based on the current time or frame within the animation. This is indicated by the "%." For example, from 2% to 32% of 45s, the keyframe for the first image will be 100% opaque. Between 32% and 34%, the first image will begin the transition from being opaque to completely transparent.
The difference between (34% of 45s) - (32% of 45s) equals the length of time to complete the transition. Increase this difference for a longer transition.
The keyframe for the second image does the same only its' transition doesn't begin until it reaches 33% of the 45s animation. (I chose to overlap them slightly for visual appeal). Again, I use the difference between 33% and 35% to keep the transition time short, rather than 0% and 35% which would've produced a much longer transition.
The third keyframe follows the same scheme for its image.
As you implement this, don't forget to change / add the appropriate vendor prefix for your browser and browser of your web audience.
/*Chrome/Safari: -webkit- \ FireFox +4: -moz- \ Opera: -o- \ IE9?: -ms- */
I hope this is helpful to anyone else who may be trying to do the same. If you like what you've read, please feel free to let me know as you vote using the up-arrow.
Thanks.
=)
#imgContainer img{
position:absolute;
left:0;
}
#image0 {
-moz-animation: 45s linear 0s normal none infinite myKeyFrameName0;
}
#image1 {
-moz-animation: 45s linear 0s normal none infinite myKeyFrameName1;
}
#image2 {
-moz-animation: 45s linear 0s normal none infinite myKeyFrameName2;
}
#-moz-keyframes myKeyFrameName0 {
0% {opacity: 0;}
2% {opacity: 1;}
32% {opacity: 1;}
34% {opacity: 0;}
100% {opacity: 0;}
}
#-moz-keyframes myKeyFrameNamee1 {
0% {opacity: 0;}
33% {opacity: 0;}
35% {opacity: 1;}
65% {opacity: 1;}
67% {opacity: 0;}
100% {opacity: 0;}
}
#-moz-keyframes myKeyFrameName2 {
0% {opacity: 0;}
66% {opacity: 0;}
68% {opacity: 1;}
98% {opacity: 1;}
100% {opacity: 0;}
}

Related

Make div appear intermittently using Animation css property not working

My goal is to have 4 colorful squares whose opacity goes from 0 to 1 intermittently to show something is loading.
I used css animation property (see below) to achieve that - but it doesn't work!
CSS
animation: opacity 1.5s infinite 200ms
I have implemented it on codepen. Can someone tell me how to fix it?
This is because you have no keyframe animation assigned to you "opacity" animation. You need to create a keyframe animation for this to work:
(I changed the animation name to "fade" instead of "opacity")
CSS
.loader-block:nth-child(1) {
background: red;
animation: fade 1.5s infinite 100ms;
}
...
#-webkit-keyframes fade {
from {opacity: 1;}
to {opacity: 0;}
}
#keyframes fade {
from {opacity: 1;}
to {opacity: 0;}
}
CodePen
PS: You also should close out all of your CSS properties with a semicolon (;). I noticed there were a few missing.
You didn't have an animation called 'opacity' so there was no animation being called. In terms of a best practice -- you probably shouldn't have an animation have a name that's also a css property so I renamed it to blink.
Here is a codepen: http://codepen.io/anon/pen/ALEEGQ
#keyframes blink{
from {opacity: 1;}
to {opacity: 0; }
}
.loader-block:nth-child(1) {
background: red;
animation: blink 1.5s infinite 100ms;
}
...

Css transition not working on mozilla

I am building an transition with :after css and content in it using below code and Its working fine on chrome but not working on firefox 26.0. Why ?
Where i did wrong? I could not understand it ?
Help me out
<html>
<head>
<style type="text/css">
.teacherheading {
display: inline-block;
font-size:20px;
}
.teacherheading::after{content:'educational';
animation: 8s ease-out 2s pulsate;
animation-iteration-count: infinite;
-webkit-animation: 8s ease-out 2s pulsate;
-webkit-animation-iteration-count: infinite;
-moz-animation: 8s ease-out 2s pulsate;
-moz-animation-iteration-count: infinite;
-o-animation: 8s ease-out 2s pulsate;
-o-animation-iteration-count: infinite;
}
#-keyframes pulsate {
0% {content:'educational';}
25% {content:'testprep';}
50% {content:'tutoring';}
75% {content:'training';}
100% {content:'educational';}
}
#-webkit-keyframes pulsate {
0% {content:'educational';}
25% {content:'testprep';}
50% {content:'tutoring';}
75% {content:'training';}
100% {content:'educational';}
}
#-moz-keyframes pulsate {
0% {content:'educational';}
25% {content:'testprep';}
50% {content:'tutoring';}
75% {content:'training';}
100% {content:'educational';}
}
#-o-keyframes pulsate {
0% {content:'educational';}
25% {content:'testprep';}
50% {content:'tutoring';}
75% {content:'training';}
100% {content:'educational';}
}
</style>
<body>
<div style="font-size:20px">
Start your <div class="teacherheading"></div> institution
</div>
</body>
</html>
The content property is not meant to be animatable.
Chrome seems to allow this (I do not know why) but Firefox is somewhat stricter.
Basically FF is following the intended behaviour, Chrome is not.
Content # MDN
From Chris Coyier at CSS-Tricks
In my own testing animating content has only worked in stable desktop Chrome (v46 at time of writing). No support anywhere else. No Safari on desktop or iOS. No Firefox. No IE. Each of these browsers will ignore the animation, showing only the original content in the pseudo element.
It might be a handy trick in some distant future or it might never be supported by anything. Non-standard features are always at least at some risk of being deprecated, so this Chrome support may not last forever.
If you need to change content in a cross-browser friendly way
Use JavaScript.

Css efects slide in and out

I'm trying to create a slide up/down or right/left animation, but I couldn't get it to work. How to hide the first div after some time with a sliding effect? how to play with display in animation
some help will be apreciated, this what I'm doing
<div id="div1">Fist div</div>
<div id="div2">Second div </div>
#div1{
animation: slideup 7s;
-moz-animation: slideup 7s;
-webkit-animation: slideup 7s;
-o-animation: slideup 7s;
}
#div2
{
position:relative;
}
#keyframes slideup
{
0% {top:0px;}
75% {top:0px;}
100% {top:-20px;}
}
#-moz-keyframes slideup
{
0% {top:0px;}
75% {top:0px;}
100% {top:-20px;}
}
#-webkit-keyframes slideup
{
0% {top:0px;}
75% {top:0px;}
100% {top:-20px;}
}
#-o-keyframes slideup
{
0% {top:0px;}
75% {top:0px;}
100% {top:-20px;}
}
No way to do this just with CSS and HTML. However it is possible to do with JavaScript. With JavaScript you can detect when the animation has ended using an Event Listener. Then you can remove or hide the div you want.
var div = document.getElementById("div1");
//add the event listener
div.addEventListener("animationend", function(event){
document.getElementById("div2").style.display = "none";
});
//you will need to explicitly add the class that contains the animation
div.classList.addClass("animate");
Change your CSS to be declared on the class .animate instead of on #div1. Also, be aware of browser prefixes. For more detail refer to this link.

Can I make transitions within a CSS animation quicker?

So my goal is to have a pure CSS background image that just fades in and out of different images.. it works and is great, I'm just wondering if there is anyway to make the transitions quicker so I don't have to see both images eased together.. I know there are different ways of controlling how that transition happens using the timing function - I'm just wondering if there is any other way? I tried using different keyframe stop points to call the next image followed by the same image 2% later to in my mind, complete the transition quicker but it didn't seem to work.. any ideas?
http://jsfiddle.net/FE948/
<div></div>
body {
background-image:url('http://patheoslabs.com/valuesandcapitalism/wp-content/uploads/2014/02/headerbg.jpg') !important;}
#-webkit-keyframes slider {
25% {background-image:url('http://patheoslabs.com/valuesandcapitalism/wp-content/uploads/2014/02/headerbg.jpg');}
48% {background-image:url('http://patheoslabs.com/valuesandcapitalism/wp-content/uploads/2014/03/headerbg2.jpg');}
50% {background-image:url('http://patheoslabs.com/valuesandcapitalism/wp-content/uploads/2014/03/headerbg2.jpg');}
73% {background-image:url('http://patheoslabs.com/valuesandcapitalism/wp-content/uploads/2014/03/headerbg3.jpg');}
75% {background-image:url('http://patheoslabs.com/valuesandcapitalism/wp-content/uploads/2014/03/headerbg3.jpg');}
97% {background-image:url('http://patheoslabs.com/valuesandcapitalism/wp-content/uploads/2014/02/headerbg.jpg');}
99% {background-image:url('http://patheoslabs.com/valuesandcapitalism/wp-content/uploads/2014/02/headerbg.jpg');}
}
body {
-webkit-animation-direction: normal;
-webkit-animation-duration: 27s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-name: slider;
-webkit-animation-timing-function: ease;
}
Thanks in advance!
Use the following keyframe percentages.
#-webkit-keyframes slider {
32% {background-image:url('http://patheoslabs.com/valuesandcapitalism/wp-content/uploads/2014/02/headerbg.jpg');}
34% {background-image:url('http://patheoslabs.com/valuesandcapitalism/wp-content/uploads/2014/03/headerbg2.jpg');}
65% {background-image:url('http://patheoslabs.com/valuesandcapitalism/wp-content/uploads/2014/03/headerbg2.jpg');}
67% {background-image:url('http://patheoslabs.com/valuesandcapitalism/wp-content/uploads/2014/03/headerbg3.jpg');}
98% {background-image:url('http://patheoslabs.com/valuesandcapitalism/wp-content/uploads/2014/03/headerbg3.jpg');}
100% {background-image:url('http://patheoslabs.com/valuesandcapitalism/wp-content/uploads/2014/02/headerbg.jpg');}
}
These should allow for quicker transitions.

looping background what do i need to use?

hello fellow developers and developers in education.
today i saw this cool effect on this website header
https://www.premiumsmoking.com/nl/e-sigaret/megatwix.html
the smoke effect that keeps looping i thought was very cool so i tried to remake it,
i tried to do this using css animation but the problem i found was when the div with the
background was on like 80% you start to see the black space left to the div.
i want to make it that it looks like its an no ending cicle. (maybe something with fadein?)
this is the code i have now
.element {
width:3000px;
height:1000px;
background-image:url(moveimage1.png);
position:relative;
margin:10px;
z-index: -1;
animation:myfirst 200s infinite;
}
#keyframes myfirst
{
0% {opacity: 0.25; margin-left: -1500px; }
50% {opacity: 1;}
100% {opacity: 0.25; margin-left: 1000px; }
}
i realy hope someone can help me with this "problem"
(if im doing something wrong in this post im sorry ,first time im asking a question on stack overflow)
already thx for reading my question.
--edit--
For everyone that also wants to use this this is my final code :
.element {
width:100%;
height:1000px;
background-image:url(moveimage1.png);
background-size: 3000px 1000px;
float: left;
position:relative;
z-index: -1;
animation:myfirst 10s infinite linear;
}
#keyframes myfirst
{
0% {opacity: 0.25; background-position: 0; }
50% {opacity: 1;}
100% {opacity: 0.25; background-position: 3000px; }
}
Much thanx for loki
You're trying to move the block, not the background inside it. I suggest animating background-position property, not margin-left. You won't have any black space anymore as long as your background image repeats