I am a novice.. I want to hover on the bottle and have the bottle rotate. At the same time I want to show the pouring and puddling animation. I don't know how I can get multiple animation to start with a single hover. Here is the CSS for it:
/*CSS ANIMATION*/
#-webkit-keyframes bottle {
0% {
height: 67px;
}
7% {
height: 67px;
}
95% {
height: 0px;
}
100% {
height: 0;
}
}
#-moz-keyframes bottle {
0% {
height: 67px;
}
7% {
height: 67px;
}
95% {
height: 0px;
}
100% {
height: 0;
}
}
#bottle {
position: absolute;
top: 1055px;
right: 490px;
-webkit-transition: all .2s linear;
}
#bottle:hover {
-moz-transform: rotate(165deg);
-webkit-transform: rotate(165deg);
transform: rotate(165deg);
-webkit-transition: all .2s linear;
}
#-webkit-keyframes pour {
0% {
background-position: 0 0;
height: 0;
}
5% {
background-position: 0 0;
height: 0;
}
10% {
background-position: 0 0;
height: 75px;
width: 4px;
}
95% {
background-position: 0 0;
height: 120px;
width: 4px;
}
100% {
background-position: 0 0;
height: 170px;
width: 4px;
}
}
#-webkit-keyframes puddle {
10% {
height: 30px;
}
15% {
height: 30px;
}
98% {
height: 50px;
}
100% {
height: 0;
}
}
#pour {
position: relative;
right: -55px;
top: -25px;
}
#puddle {
position: relative;
top: -50px;
opacity: 1;
right: -20px;
}
#contents1:hover {
-moz-animation: bottle 5s linear 1 forwards;
-webkit-animation: bottle 5s linear 1 forwards;
animation: bottle 5s linear 1 forwards;
}
#contents2:hover {
display: block;
-moz-animation: pour 2s linear 1;
-webkit-animation: pour 2s linear 1;
animation: pour 2s linear 1;
}
#contents3:hover {
-moz-animation: puddle 10s linear 1;
-webkit-animation: puddle 10s linear 1;
animation: puddle 10s linear 1;
}
Now I need to know how to connect contents2:hover and contents3:hover with the bottle:hover. I mean just by hovering over the bottle, how can I set contents2 and contents3 in motion?
As you guys have requested i ve uploaded everything to JSFiddle.. This is the link http://jsfiddle.net/shettyrahul8june/8tkKK/2/
And for fullscreen jsfiddle.net/shettyrahul8june/8tkKK/2/embedded/result/
For some reasons the bottle.png is not being displayed in the editors link but works fine in fullscreen.. This is the link for the image s26.postimg.org/s07bc6gvp/bottle.png .... All i want is to the bottle to rotate and pour the liquid and then comes the puddle.. All should happen with single bottle hover.. I'm not simply relying on people.. I've worked hard but couldn't get it right.. Also if someone could put light on how to maintain the resolution of the webpage, it'd be a great help.. Hope i am precise.. Please do help because many are searching for this and this could be their ultimate stop..
You are looking for Tilde ~ selector in CSS
Working Demo and Source
CSS
#bottle:hover ~ #pour {
display: block;
-moz-animation: pour 2s linear 1;
-webkit-animation: pour 2s linear 1;
animation: pour 2s linear 1;
}
#bottle:hover ~ #puddle {
-moz-animation: puddle 10s linear 1;
-webkit-animation: puddle 10s linear 1;
animation: puddle 10s linear 1;
}
Related
I'm trying to slide a few elements one after the other on the page.
Basically, I need to slide the first element in, and then the second after and then the third one etc etc.
Something like this:
This is what i have so far:
https://jsfiddle.net/npvsrkcy/3/
In the fiddle above, all the elements/images will slide in all at the same time which is not what i am looking for.
This is my entire code:
img {
position: relative;
margin-left: 0%;
margin: 1em;
animation: slide 4s 1;
width:100%;
}
#keyframes slide {
from { right: -150%; }
to { right: 0%; }
}
Could someone please advise on this?
EDIT:
Ok, since I'm trying to use the slide animation on dynamically created elements, I can't use the normal nth-child~(number) scenario.
So I tried to do this:
img:nth-child(1n+3) {
-webkit-animation-delay: 0;
animation-delay: 0;
}
img:nth-child(2n+2) {
-webkit-animation-delay: 0.2s;
animation-delay: 0.2s;
}
img:nth-child(3n+3) {
-webkit-animation-delay: 0.4s;
animation-delay: 0.4s;
}
but that seems to only work for the first 3 elements/images!
This is the new fiddle: https://jsfiddle.net/npvsrkcy/9/
You might try to leverage the nth-child(number) selector to delay the animation, like so:
img {
position: relative;
margin-left: 0%;
margin: 1em;
animation: slide 4s 1;
width:100%;
/* Fix the elements being visible before the animation */
opacity: 0;
/* After the animation remain visible */
-webkit-animation-fill-mode: forwards; /* Safari 4.0 - 8.0 */
animation-fill-mode: forwards;
}
img:nth-child(1) {
-webkit-animation-delay: 0;
animation-delay: 0;
}
img:nth-child(2) {
-webkit-animation-delay: 1s;
animation-delay: 1s;
}
img:nth-child(3) {
-webkit-animation-delay: 2s;
animation-delay: 2s;
}
#keyframes slide {
from { right: -150%; opacity: 0;}
to { right: 0%; opacity: 1; }
}
This would delay the animation of the second and third image element by the set amount of seconds.
Hope it helps!
Edit: just played with the fiddle, and it seems that an edit to the animation would be desirable to prevent them from showing before loading. Allow me to come up with a fix;
Edit 2: Fixed it by setting the animation-fill-mode to forwards and added an opacity effect. Another solution would be to place the image off-screen to starty with.
PS. Some further info:
https://www.w3schools.com/cssref/sel_nth-child.asp
you can try this :
img {
position: relative;
margin-left: 0%;
margin: 1em;
animation: Aslide 4s 1;
width:100%;
}
img + img {
animation: Bslide 4s 1;
}
img + img + img {
animation: Cslide 4s 1;
}
#keyframes Aslide {
0% { right: -150%; }
33.333333% { right: 0%; }
66.666666% { right: 0%;}
100% { right: 0%;}
}
#keyframes Bslide {
0 { right: -150%; }
33.333333% { right: -150%; }
66.666666% { right: 0%;}
100% { right: 0%;}
}
#keyframes Cslide {
0% { right: -150%; }
33.333333% { right: -150%; }
66.666666% { right: -150%; }
100% { right: 0%;}
}
Delay the animation for each div (and)
Add a fill-mode and set right value to -150% for img tag by default
img {
position: relative;
margin-left: 0%;
margin: 1em;
animation: slide 4s 1 forwards;
width:100%;
right: -150%;
}
img:nth-child(1) {
animation-delay:0s;
}
img:nth-child(2) {
animation-delay:1s;
}
img:nth-child(3) {
animation-delay:2s;
}
#keyframes slide {
from { right: -150%; }
to { right: 0%; }
}
I have added on my site loading animation prepared in CSS code. I have a problem because when the animation ends it all on the page is locked and nothing can be a click away.
.loader2 {
height: 100%;
position: absolute;
top: 0;
z-index: 400;
width: 100%;
-webkit-animation: loader2 2s linear 0s;
-moz-animation: loader2 2s linear 0s;
-o-animation: loader2 2s linear 0s;
animation: loader2 2s linear 0s;
}
#-webkit-keyframes loader2{ 0%{ background-color: #0000FF; opacity: 1; }
100%{ background-color: #ffffff; opacity: 0; }}
and in html (at the bottom of the code): <div class="loader2"></div>
I solved this problem, but it adds additional animations, which I do not need.
#-webkit-keyframes loader2{ 0%{ background-color: #0000FF; opacity: 1; width: 100%; }
100%{ background-color: #ffffff; opacity: 0; width: 0%; }}
try to change the z-index property on the last keyframe, setting a negative value
#-webkit-keyframes loader2{
0% { background-color: #0000FF; opacity: 1; z-index: 400; }
99.9% { background-color: #ffffff; opacity: 0; z-index: 400; }
100% { z-index: -1; }
}
Firefox is ignoring the declaration for the first animation (cursorfadein), while showing the animations that handle the moving and fading out just fine. I've tried using units like 0s and 0msCode below.
#-moz-keyframes cursorfadein {
0% { opacity: 0; }
100% { opacity: 1; }
}
#-moz-keyframes cursormover {
0% {
top: 300px;
right: 90px;
}
50%, 60% {
top: 204px;
right: 234px;
}
100% {
top: 300px;
right: 290px;
}
}
#-moz-keyframes cursorhider {
0% { opacity: 1; }
100% { opacity: 0; }
}
.cursor {
position: absolute;
background: url(https://cdn.mediacru.sh/A/AhRlh9cYN5sf.png) no-repeat;
background-size: contain;
display: block;
height: 20px;
width: 20px;
-webkit-animation: cursorfadein 3s ease 0s, cursormover 3s ease-in-out 2s both, cursorhider 1s linear 6s both;
-moz-animation: cursorfadein 3s ease 0s, cursormover 3s ease-in-out 2s both, cursorhider 1s linear 6s both;
animation: cursorfadein 3s ease 0s, cursormovein 3s ease-in-out 2s both, cursorhider 1s linear 6s both;
}
I have the -webkit- and non-prefixed #keyframes as well (included in the Codepen), just wanted to be brief here on SO
Codepen here.
Html5:
<div id="slideshow">
<div id='animate-area'>
</div>
</div>
Css:
body {
margin: 0;
padding: 0;
}
#slideshow {
position: relative;
overflow: hidden;
height: 145px;
}
#animate-area {
height: 100%;
width: 2538px;
position: absolute;
left: 0;
top: 0;
background-image: url('../img/banner.png');
animation: animatedBackground 40s 5s linear infinite;
-ms-animation: animatedBackground 40s linear infinite;
-moz-animation: animatedBackground 40s linear infinite;
-webkit-animation: animatedBackground 30s linear infinite;
}
/* Put your css in here */
#keyframes animatedBackground {
from { left: 0; }
to { left: -1269px; }
}
#-webkit-keyframes animatedBackground {
from { left: 0; }
to { left: -1269px; }
}
#-moz-keyframes animatedBackground {
from { left: 0; }
to { left: -1269px; }
}
JSfiddle:
jsfiddle.net/cz04c4nx/1
Using this image, I need show like, http://jsfiddle.net/5pVr4/6/. I tried, but for my particular image url('../img/banner.png') when run in localhost, can't able to get.
I think i solved your problem. You can use this code and it may be help you.I edited that code which you can make similar animate background image.
CSS Code:
#-webkit-keyframes MOVE-BG {
from {
-webkit-transform: translateX(0);
}
to {
-webkit-transform: translateX(-550px);
}
}
#content {
height: 100px;
text-align: center;
font-size: 26px;
color: white;
position: relative;
overflow: hidden;
}
.bg{
position: absolute;
left: 0;
right: -550px;
top: 0;
bottom: 0;
background: url(http://s30.postimg.org/qnju89rkx/banner.png) 0% 0% repeat;
z-index: -1;
-webkit-animation-name: MOVE-BG;
-webkit-animation-duration: 10s;
-webkit-animation-timing-function: linear;
-webkit-animation-iteration-count: infinite;
}
Live Working Demo
I'm having issues in Chrome browser getting my animations to work correctly. Upon page load the first span in rw-words-1 is always off in its positioning for some reason. On the website when the page loads, it is supposed to read like...
Building "some text 1"
designed to "some word 1"
and then the words i've placed in quotes should fade out and the new words pop in like...
Building "some text 2"
designed to "some word 2"
etc, etc based on the html file below. The problem is the 2nd and 3rd span pop in the correct positioning, but the 1st span is always jumbled & overlapping the "designed to" text for some reason. It works fine however in Firefox / Safari. Any help would be much appreciated.
FRONT-END HTML
<div class="slogan">
<h1 class="rw-sentence">
<span>Building</span>
<div class="rw-words rw-words-1">
<span>some text 1...</span>
<span>some text 2...</span>
<span>some text 3...</span>
</div>
<br clear="all">
<span>designed to</span>
<div class="rw-words rw-words-2">
<span>some word 1</span>
<span>some word 2</span>
<span>some word 3</span>
</div>
</h1>
<p>Some sub-slogan here</p>
</div>
CSS:
/* ------ CSS ANIMATIONS ------- */
.rw-wrapper {
width: 90%;
padding: 10px;
}
.rw-sentence{
text-align: left;
position: relative;
}
.rw-sentence span {
white-space: nowrap;
}
.rw-words {
display: inline;
}
.rw-words span{
position: absolute;
opacity: 0;
width: 100%;
/* overflow: hidden; */
font-weight: bold;
}
.rw-words.rw-words-1 span {
margin-left: 0px;
}
/* -- WEIRD FIREFOX MARGIN HACK --*/
#-moz-document url-prefix() {
.rw-words.rw-words-1 span {
margin-left: 10px;
}
}
.rw-words.rw-words-2 span {
margin-left: 10px;
}
.rw-words-1 span{
animation: rotateWordsSecond 18s linear infinite 0s;
-webkit-animation: rotateWordsSecond 18s linear infinite 0s;
-moz-animation: rotateWordsSecond 18s linear infinite 0s;
-ms-animation: rotateWordsSecond 18s linear infinite 0s;
}
.rw-words-2 span{
animation: rotateWordsSecond 18s linear infinite 0s;
-webkit-animation: rotateWordsSecond 18s linear infinite 0s;
-moz-animation: rotateWordsSecond 18s linear infinite 0s;
-ms-animation: rotateWordsSecond 18s linear infinite 0s;
}
.rw-words span:nth-child(2) {
-webkit-animation-delay: 6s;
-moz-animation-delay: 6s;
-ms-animation-delay: 6s;
animation-delay: 6s;
}
.rw-words span:nth-child(3) {
-webkit-animation-delay: 12s;
-moz-animation-delay: 12s;
-ms-animation-delay: 12s;
animation-delay: 12s;
}
#keyframes rotateWordsFirst {
0% { opacity: 1; animation-timing-function: ease-in; height: 0px; }
8% { opacity: 1; height: 60px; }
19% { opacity: 1; height: 60px; }
25% { opacity: 0; height: 60px; }
100% { opacity: 0; }
}
#-moz-keyframes rotateWordsFirst {
0% { opacity: 1; animation-timing-function: ease-in; height: 0px; }
8% { opacity: 1; height: 60px; }
19% { opacity: 1; height: 60px; }
25% { opacity: 0; height: 60px; }
100% { opacity: 0; }
}
#-webkit-keyframes rotateWordsFirst {
0% { opacity: 1; animation-timing-function: ease-in; height: 0px; }
8% { opacity: 1; height: 60px; }
19% { opacity: 1; height: 60px; }
25% { opacity: 0; height: 60px; }
100% { opacity: 0; }
}
#keyframes rotateWordsSecond {
0% { opacity: 1; animation-timing-function: ease-in; width: 0px; }
10% { opacity: 1; width: 0px; }
20% { opacity: 1; width: 100%; }
27% { opacity: 0; width: 100%; }
100% { opacity: 0; }
}
#-moz-keyframes rotateWordsSecond {
0% { opacity: 1; animation-timing-function: ease-in; width: 0px; }
10% { opacity: 1; width: 0px; }
20% { opacity: 1; width: 100%; }
27% { opacity: 0; width: 100%; }
100% { opacity: 0; }
}
#-webkit-keyframes rotateWordsSecond {
0% { opacity: 1; animation-timing-function: ease-in; width: 0px; }
10% { opacity: 1; width: 0px; }
20% { opacity: 1; width: 100%; }
27% { opacity: 0; width: 100%; }
100% { opacity: 0; }
}
Well...I just changed some code around & added some margins/floats & it now works in all browsers. Still not sure why chrome treated the transitions/code from my original question differently though which is pretty frustrating. If anybody knows, i'd still love to know as I'm trying to get better at design that's consistent across all browsers. thx,
.rw-words {
display: inline;
float: left;
}
.rw-words span{
position: absolute;
opacity: 0;
width: 100%;
/* overflow: hidden; */
font-weight: bold;
}
.rw-words.rw-words-1 span {
margin-left: 165px;
font-weight: 480;
}
/* -- I REMOVED THE FIREFOX MARGIN HACK --*/
.rw-words.rw-words-2 span {
margin-left: 234px;
font-weight: 480;
}