I am trying to do a css3 animation on multiple elements.
All those elements have different background-image and they must be replace in the middle of the animation.
The thing is, I want to use the same animation for all elements.
Wich mean, I can't write the original background-image in the animation.
But, the absence of original background-image make the background-image animate with the rest.
I think I would need something like:
background-image: default;
But I don't think it exist.
Anyone have an idea?
Example:
http://jsfiddle.net/4SRrR/
(Look how the background-image start fading to the red one before the div is out of the screen.)
Html:
<div class="anim"></div>
Css:
.anim {
position: absolute;
top: 0;
left: 0;
width: 400px;
height: 400px;
background-image: url("http://www.webdesign.org/img_articles/15485/Step1.png");
-webkit-animation: anim .75s forwards ease-in;
}
#-webkit-keyframes anim {
0% {-webkit-transform: translateX(0px);}
50% {-webkit-transform: translateX(-400px);}
51% {-webkit-transform: translateX(-400px); background-image: url("http://www.vt2k.com/processing/images/redball.jpg");}
100% {-webkit-transform: translateX(0px); background-image: url("http://www.vt2k.com/processing/images/redball.jpg");}
}
One posibility would be to have 2 backgrounds, and then in the animation just reference the sizes of the first and the second one:
fiddle
The CSS would be:
.anim {
position: absolute;
top: 0;
left: 0;
width: 400px;
height: 400px;
background-image: url("http://www.webdesign.org/img_articles/15485/Step1.png"), url("http://www.vt2k.com/processing/images/redball.jpg");
background-size: 100% 100%, 0% 100%;
background-repeat: no-repeat;
-webkit-animation: anim 7.5s forwards ease-in;
}
#-webkit-keyframes anim {
0% {-webkit-transform: translateX(0px); background-size: 100% 100%, 0% 0%;}
50% {-webkit-transform: translateX(-400px);background-size: 100% 100%, 0% 0%;}
51% {-webkit-transform: translateX(-400px); background-size: 0% 0%, 100% 100%; }
100% {-webkit-transform: translateX(0px); background-size: 0% 0%, 100% 100%;}
}
I have increased the duraion of the transition so that it is more visible. And also overdefined the background-size; it wouldn't be necesary to repeat it in every frame.
I'm confused as to what the question is but I'll take a stab at it. If you take the 51% animation off then it seems to work slightly better. It will shrink until it is gone and then as it comes back the background-image fades in.
One of the hard things with CSS3 animations is that there isn't an easy way to tell when the animation is 50% done. What you could do is 2 keyframe animations. With JS you can listen for the first animation ending. You could add the background-image and then the class that will trigger the second part of the animation. It's not pretty but could work.
Related
I am trying to create an animation background in a small div, but chrome is getting me unknown property name for the #keyframes all time, and I have the gradient, but I am unable to sho the animation.
#keyframes gradient {
0% {background-position: 0%}
100% {background-position: 100%}
}
#-webkit-keyframes gradient {
0% {background-position: 0%}
100% {background-position: 100% }
}
.labelSincroAlert {
text-align: center !important;
width: 100%;
position: absolute;
bottom: 0px;
left: 0px;
background: -webkit-linear-gradient(45deg,#F17C58, #E94584, #24AADB , #27DBB1,#FFDC18, #FF3706);
background-size: 600% 100%;
animation: gradient 16s ease infinite;
-webkit-animation: gradient 16s ease infinite;
animation-direction: alternate;
}
I'm using cuba framework and scss for this, It's important?
Here in the inspector is where I get the error
This only happends to me because I am doing an extension from the cuba-platform hellium theme. I don't know how to solve it.
The problem is I was using helium-ext.scss, and in this cases you have to use helium-ext-defaults.scss. It was inded related with cuba-framerwork and his theme. To solve it just put you #keyframe inside of helium-ext-defaults.scss and the rest of the code on helium-ext.scss.
Note: This question requests an explanation of CSS transform output on Chrome.
Description
I made a rhombus using css skew and rotate transforms.
I added :hover pseudo-class to that element and changed its skew angle.
The expected result was that on hovering the rhombus, the angle of the rhombus will change.
Here is the fiddle and
snippet :
div {
height: 200px;
width: 200px;
position: relative;
top: 140px;
left: 120px;
-webkit-transform: rotate(-45deg) skew(10deg, 10deg);
-moz-transform: rotate(-45deg) skew(10deg, 10deg);
transform: rotate(-45deg) skew(10deg, 10deg);
background: red;
transition: 0.8s linear all;
}
div:hover {
-webkit-transform: rotate(-45deg) skew(-30deg, -30deg);
-moz-transform: rotate(-45deg) skew(-30deg, -30deg);
transform: rotate(-45deg) skew(-30deg, -30deg);
transition: 0.8s linear all;
}
<div></div>
Problem
This is working fine on Firefox v35.0.1 and IE v10. See the output below :
But on Chrome 40.0.2214.115, the output seems to be different. The angle of the rhombus changes, but not evenly. And near the end of transition of transform property, the rhombus "step-ends" to the desired output, instead of transforming transitionally.
Its neither working with skewX(Xdeg) skewY(Ydeg) nor skew(Xdeg, Ydeg) : fiddle.
The GC output is below :
Question : Chrome seems to support the deprecated skew(Xdeg, Ydeg) but the output with transition is buggy. * What is causing this strange output with chrome?**
Note: This effect is achievable using scaleX transform too, but this is a deliberately made question.
You could try using clip-path: polygon() to achieve the same effect. Not yet supported in all browsers unfortunately.
div {
width: 200px;
height: 280px;
background: red;
-webkit-clip-path: polygon(50% 20%, 100% 50%, 50% 80%, 0% 50%);
clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
transition: all 0.5s ease;
}
div:hover {
-webkit-clip-path: polygon(50% 0%, 80% 50%, 50% 100%, 20% 50%);
clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}
/* center */
html, body { height: 100%; }
body {
display: flex;
justify-content: center;
align-items: center;
}
<div></div>
I have been working with transitions now on chrome. I find using position tags like this.
div:hover {
position:relative; /*Desribes the type of position*/
left:40; /*X Coordinate*/
top:25; /*Y Coordinate*/
}
Make the transitions work on chrome.
Here are some resources
-https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Using_CSS_transitions
-http://blog.wercker.com/2013/10/02/Chrome-css-animation.html
Hope it helped :)
This is bugging me, because I know that this is possible, I just don't really know how to write it properly. Here's an image of my vision:
So far in my css, I've implemented the cloud animation
#home{
margin: 0;
padding-top: 327px;
height: 57.78vh;
background: #6bbfff url('../images/clouds.png') repeat-x fixed 50% 10%;
text-align: center;
-webkit-animation: cloudmove 180s infinite linear;
animation: cloudmove 180s infinite linear;
}
#keyframes cloudmove{
0% { background-position: 0% 10%; }
100% { background-position: 100% 10%; }
}
#-webkit-keyframes cloudmove{
0% { background-position: 0% 10%; }
100% { background-position: 500% 10%; }
}
I've been trying to add the landscape illustration in the image shown above as background image number 2, but I'm having trouble. How do I get the css animation to not apply to it?
Thanks!
You do it like this:
Fiddle
Your pertinent CSS relies on some new features of backgrounds in CSS3.
Layered background images
You can instantiate these like so:
.my-rule {
background-image: url(image1.png), url(image2.png);
background-position: 0 0, 50% 50%;
}
It's pretty simple! You just need to separate all rules for each respective background image with commas. That goes straight down to your animations as well, like so:
#keyframes cloudmove{
0% { background-position: 0% 10%, 0% 0%; }
100% { background-position: 100% 10%, 100% 0%; }
}
#-webkit-keyframes cloudmove{
0% { background-position: 0% 10%, 0% 0%; }
100% { background-position: 500% 10%, 100% 0%; }
}
Hope that helps!
I would like to keep the left edge of div.box in the same place during a transformY(-180deg) animation. I can't understand why is it moving. This is the code:
transform-origin: 0% 0%;
transform: rotateY(-180deg);
And here is the live example http://dabblet.com/gist/5551520
You're also transitioning the transform-origin, as you use transition: all, and it is specified in the hover state. The initial value is to be centred.
If you put transform-origin: 0% 0%; on .box it will work as expected.
.box {
/* removed additional styles */
transition: all 600ms linear;
transform-origin: 0% 0%;
}
body:hover .box {
transform: rotateY(-180deg);
}
http://dabblet.com/gist/5551730
I have the following letters ABC as shown below:
<body>
<div id="container">
<div id="shape" class="spin">
<div id="A" class="plane">A</div>
<div id="B" class="plane">B</div>
<div id="C" class="plane">C</div>
</div>
</div>
What I want is each letter to spin around its x-axis?
I tried (for letter C):
#C {
-webkit-animation: spinAboutItsCentre 8s linear;
}
#-webkit-keyframes spinAboutItsCentre {
from {
-webkit-transform: rotateX(0);
}
to {
-webkit-transform: rotateX(360deg);
}
}
but the letter C moves over to where the letter A is an spins it its axis.
Any ideas?
JD
It should look something like this, you need to specify your transform-origin properties;
x-%, y-%, and z-px.
Notice spinning about the Y-axis creates a bit of offset because the engine's interpretation of the character's position originates at the "beginning" (side) of the object, not the center of the object.
The 0% and 100% designations represent your "from" and "to" clauses, this format allows you to add as many of these lines as you wish to increment the movement over your specified timeframe (i.e. 25% rotate 90deg, 50% rotate 180deg, 75% rotate 270deg, 100% rotate 360deg).
#-webkit-keyframes spinX
{
0% {-webkit-transform: rotateX(0deg); -webkit-transform-origin: 0% 50% 0;}
100% {-webkit-transform: rotateX(360deg); -webkit-transform-origin: 0% 50% 0;}
}
#-webkit-keyframes spinY
{
0% {-webkit-transform: rotateY(0deg); -webkit-transform-origin: 0% 0% 5;}
100% {-webkit-transform: rotateY(360deg); -webkit-transform-origin: 0% 0% 5;}
}
Try these styles, they should work alright.
#Ca
{
position: absolute;
left: 20%;
font-size:72px;
-webkit-animation: spinX 8s infinite;
}
#Cb
{
position: absolute;
left: 20%;
font-size:72px;
-webkit-animation: spinY 8s infinite;
}
<div id="Ca">C</div>
<div id="Cb">C</div>
Transforms have a "transform-origin" associated with them. When no transform origin is specified, it is automatically set at (50%, 50%) of the element. When your exact code is entered as a jsfiddle, it works as intended.
My guess is that in your complete code you have specified a transform origin incorrectly or have other weirdness in the base CSS for your class.
Update: So, yes, you had weirdness in the base CSS. It would be helpful to see your complete CSS and HTML for debugging.