i have a problem when making Flip Clock animation
the animation will perform like this reference
reference : http://hilios.github.io/jQuery.countdown/
so far, this is my work.
demo : https://jsfiddle.net/s3qk25m7/1
i try this one :
HTML :
<div class="time">
<span class="count top flipTop">2</span>
<span class="count top">1</span>
<span class="count bottom flipBottom">1</span>
<span class="count bottom">2</span>
</div>
CSS :
.time {position: relative; height: 95px; width: 65px;
perspective: 200px; backface-visibility: hidden;
transform: translateZ(0); transform: translate3d(0,0,0);
}
.count {background: #202020; color: #f8f8f8; display: block;
font-size: 2em; line-height: 2.4em; overflow: hidden;
position: absolute; text-align: center;
top: 0; width: 100%;
}
.top {height: 50%; line-height:95px; transform-origin: 50% 100%; }
.bottom {line-height: 0; height: 50%; top: 50%; transform-origin: 50% 0; }
#keyframes flipTop {
from {
transform: rotateX(0deg);
}
to {
transform: rotateX(-90deg);
}
}
#keyframes flipBottom {
from {
transform: rotateX(90deg);
}
to {
transform: rotateX(0deg);
}
}
.flipTop {
animation-name: flipTop;
animation-duration: 0.25s;
animation-fill-mode: both;
}
.flipBottom {
animation-name: flipBottom;
animation-duration: 0.25s;
animation-delay: 0.25s;
animation-fill-mode: both;
}
the animation not working properly. how to solve this issue?
what's wrong with my code?
thanks in advance...
The issue is that the animated div is behind the static.
To fix this add z-index: 1 to your .flipPosition class.
Check out this updated fiddle
Edit: note that the lower div's number seems to be updated too early
Edit 2: I just realized that ngAnimateSwap would probably be perfect for this!
Related
I have a css transition so that when someone hovers over an image, the h2 will grow. It does kind of work, but the in addition to growing the h2 is also moving across the div. This has never happened to me before and I can't figure out why. You can see it's behavior here, if you scroll to the bottom of the page and hover over Our Story and Our Team: https://katherinemade.com/staging/mission-vision-values/
Here is my html:
<div class="img-relative-position">
<h2 class="over-image-text">Our Story</h2>
<img />
</div>
And my css:
.img-relative-position {
position: relative;
}
.over-image-text {
position: absolute;
top: 45%;
left: 50%;
transform: translate(-50%, -50%);
}
.img-relative-position h2 {
transition: all .2s ease-in-out;
}
.img-relative-position:hover h2 {
transform: scale(1.5);
}
Does anyone know what could be causing my h2 to move vertically across the div, and how I can keep it center but still grow?
You can do like this
.img-relative-position {
position: relative;
}
.over-image-text {
position: absolute;
top: 45%;
left: 50%;
transform: translate(-50%, -50%);
}
.img-relative-position h2 {
transition: all .2s ease-in-out;
}
.img-relative-position:hover h2 {
transform: scale(1.5);
}
<div class="img-relative-position">
<div class = "over-image-text"> //new div
<h2 class="over-image-text-cstm">Our Story</h2>
</div>
<img />
</div>
i think you should scale a "parent" Container so if you create something like this
<div class="img-relative-position"> // <-- the Image
<div class="scale-this-on-hover"> // <-- new container this one has to be scaled
<h2 class="over-image-text">Our Story</h2>
<img />
</div>
</div>
No need To add scale property to increase text size
.img-relative-position:hover h2 {
/* transform: scale(1.5); */ // Remove This Line
font-size: 60px; // Add font-size
}
Thanks
I think you are missing transform-origin: center on h2. I have made a snippet for you. Have a look.
Thanks me later.
* {
box-sizing: border-box;
}
.wrap {
margin: 40px;
width: 300px;
height: 200px;
line-height: 200px;
background: green;
color: #fff;
text-align: center;
}
.wrap h2 {
transition: .3s ease;
transform-origin: center center;
}
.wrap:hover h2 {
transform: scale(1.5);
}
<div class="wrap">
<h2>Hello Test</h2>
</div>
For Extra Hover Effect You Can use This Css I Hope You Like It :)
.img-relative-position {
position: relative;
overflow: hidden;
}
.over-image-text {
position: absolute;
top: 45%;
left: 50%;
transform: translate(-50%,-50%);
z-index: 2;
transition: all 0.5s ease-in-out;
}
.img-relative-position:hover h2 {
font-size: 60px;
}
.img-relative-position a {
display: block;
}
.img-relative-position img {
transition: all 0.5s ease;
}
.img-relative-position:hover img {
transform: scale(1.2) rotate(-5deg);
}
Thanks
I'm trying to make it so that the rotate(-45deg) property gets delayed a shortly after the first property translateY(6px) with the help of a delay. But how do I do that?
Code:
transform: translateY(6px) rotate(-45deg);
I first thought it was something like:
transform: translateY(6px) rotate(-45deg, 2s);
There is no trivial way to do this but in your particular case you can split the transformation using two different properties. You keep the rotation within transform and you use top/bottom to add the translation.
.box {
margin: 20px;
position: relative;
width: 200px;
height: 200px;
background: red;
top: 0;
transition: transform 0.5s, top 0.5s 0.5s;
}
.box:hover {
transform: rotate(-45deg);
top: -50px;
}
<div class="box">
</div>
Or you can consider animation:
.box {
margin: 20px;
position: relative;
width: 200px;
height: 200px;
background: red;
top: 0;
}
.box:hover {
animation:change 1s linear forwards
}
#keyframes change {
50% {
transform: rotate(-45deg);
}
100% {
transform: translateY(-50px) rotate(-45deg);
}
}
<div class="box">
</div>
First time posting here, have long used the site as a resource for any problems I come across but for the first time I haven't been able to fix my code using previous answers.
There's probably a very simple answer for what I'm asking and I'm just missing something.
I am trying to create a snippet that I can use in a production site soon. I want to create an image "frame" that sits around an image. I also then want this frame to be animated and swing from side to side.
Before I insert the animation code, the code is as below, and works perfectly (the frame is above the image).
.frame {
margin-top: 5rem;
margin-left: 35%;
display: inline-flex;
background-image: url(http://www.studiopastimes.info/tester/images/frame.svg);
background-repeat: no-repeat;
z-index: 1000;
padding: 3rem;
box-sizing: border-box;
}
.internal-frame {
position: relative;
width: 400px;
z-index:-5;
}
.internal-frame img {
width: 100%;
}
However, when I add the animation code, this breaks the z-index.
#-webkit-keyframes swinging{
0%{-webkit-transform: rotate(10deg);}
33%{-webkit-transform: rotate(-5deg);}
66%{-webkit-transform: rotate(10deg);}
100%{-webkit-transform: rotate(-5deg);}
}
#keyframes swinging{
0%{-webkit-transform: rotate(10deg);}
33%{-webkit-transform: rotate(-5deg);}
66%{-webkit-transform: rotate(10deg);}
100%{-webkit-transform: rotate(-5deg);}
}
.swingimage{
-webkit-transform-origin: 50% 0;
transform-origin: 50% 0;
-webkit-animation: swinging 5s ease-in-out ;
animation: swinging 5s ease-in-out ;
animation-fill-mode: forwards;
backface-visibility: hidden;
}
This can all be seen in the Codepen here: https://codepen.io/anon/pen/RMrrWB
Any idea how I can get the CSS animation to work, whist still having the frame above the image? I understand from my research there issues with CSS animations and z-index, but I couldn't get any of the suggested fixes to work. Any help would be great and if there's any issues with how I have asked this question please let me know!
Thanks
I'd put the frame on a pseudo-element:
.frame {
margin-top: 5rem;
margin-left: 35%;
box-sizing: border-box;
width: 400px;
padding-top: 69.25%; /* this is the aspect ratio of the image: height / width */
position: relative;
}
.frame:after {
content:'';
display:block;
position: absolute;
z-index: 2;
top: 0;
left: 0;
bottom: 0;
right: 0;
background-image: url(http://www.studiopastimes.info/tester/images/frame.svg);
background-repeat: no-repeat;
padding: 20px;
}
img {
position: absolute;
top: 20px; /* match the padding */
left: 0;
width: 100%;
z-index: 1;
}
#-webkit-keyframes swinging {
0% {
-webkit-transform: rotate(10deg);
}
33% {
-webkit-transform: rotate(-5deg);
}
66% {
-webkit-transform: rotate(10deg);
}
100% {
-webkit-transform: rotate(-5deg);
}
}
#keyframes swinging {
0% {
-webkit-transform: rotate(10deg);
}
33% {
-webkit-transform: rotate(-5deg);
}
66% {
-webkit-transform: rotate(10deg);
}
100% {
-webkit-transform: rotate(-5deg);
}
}
.swingimage {
-webkit-transform-origin: 50% 0;
transform-origin: 50% 0;
-webkit-animation: swinging 5s ease-in-out;
animation: swinging 5s ease-in-out;
animation-fill-mode: both;
backface-visibility: hidden;
}
<div class="frame swingimage">
<img src="http://www.studiopastimes.info/tester/images/cabaret.jpg" class="img">
</div>
The z-index property needs the element to have a set position. then if you just add position: relative; to your .frame it'll make the job.
full css :
.frame {
margin-top: 5rem;
margin-left: 35%;
display: inline-flex;
position: relative;
background-image: url(http://www.studiopastimes.info/tester/images/frame.svg);
background-repeat: no-repeat;
position: relative
z-index: 10;
padding: 3rem;
box-sizing: border-box;
/* height: 10rem;
width: 20rem;*/
}
.internal-frame {
position: relative;
width: 400px;
z-index:-5;
}
.internal-frame img {
width: 100%;
z-index:-5;
}
#-webkit-keyframes swinging{
0%{-webkit-transform: rotate(10deg);}
33%{-webkit-transform: rotate(-5deg);}
66%{-webkit-transform: rotate(10deg);}
100%{-webkit-transform: rotate(-5deg);}
}
#keyframes swinging{
0%{-webkit-transform: rotate(10deg);}
33%{-webkit-transform: rotate(-5deg);}
66%{-webkit-transform: rotate(10deg);}
100%{-webkit-transform: rotate(-5deg);}
}
.swingimage{
-webkit-transform-origin: 50% 0;
transform-origin: 50% 0;
-webkit-animation: swinging 5s ease-in-out ;
animation: swinging 5s ease-in-out ;
animation-fill-mode: both;
backface-visibility: hidden;
}
with your html :
<!DOCTYPE html>
<html>
<head>
<title>FRAME TESTER</title>
</head>
<body>
<div class="frame">
<div class="internal-frame">
<img src="http://www.studiopastimes.info/tester/images/cabaret.jpg">
</div>
</div>
</body>
</html>
I have a 'bouncing loader' div, in which moves up and down on an infinite loop (see this jsfiddle
However, if I place a button below it, (or anything else for that matter), it will also move in time to the animation effect.
Is there anyway of stopping this button from moving?
I have tried adding margins/padding on both, but they didn't work so I removed them.
the loader html:
<div class="loader" style="float:initial;">
<span></span>
<span></span>
<span></span>
</div>
<br />
<div>
<button id="popupArea">Click here to invoke a popup window</button>
</div>
with the css being:
.loader {
text-align: center;
}
.loader span {
display: inline-block;
vertical-align: middle;
width: 10px;
height: 10px;
margin: 50px auto;
background: black;
border-radius: 50px;
-webkit-animation: loader 0.9s infinite alternate;
-moz-animation: loader 0.9s infinite alternate;
}
.loader span:nth-of-type(2) {
-webkit-animation-delay: 0.3s;
-moz-animation-delay: 0.3s;
}
.loader span:nth-of-type(3) {
-webkit-animation-delay: 0.6s;
-moz-animation-delay: 0.6s;
}
#-webkit-keyframes loader {
0% {
width: 10px;
height: 10px;
opacity: 0.9;
-webkit-transform: translateY(0);
}
100% {
width: 24px;
height: 24px;
opacity: 0.1;
-webkit-transform: translateY(-21px);
}
}
#-moz-keyframes loader {
0% {
width: 10px;
height: 10px;
opacity: 0.9;
-moz-transform: translateY(0);
}
100% {
width: 24px;
height: 24px;
opacity: 0.1;
-moz-transform: translateY(-21px);
}
}
As always, any help/advice is welcomed.
Please note, I'm don't know jquery, so would like to avoid it as much as possible (hence i'm using asp MVC)
Just add the following css attribute:
#popupArea {
position:fixed;
top:100px;//you can change the value as you wish
}
Example here.
try like this
.loader {
text-align: center;
}
.loader span {
display: inline-block;
vertical-align: middle;
width: 10px;
height: 10px;
margin: 50px auto;
background: black;
border-radius: 50px;
-webkit-animation: loader 0.9s infinite alternate;
-moz-animation: loader 0.9s infinite alternate;
}
.loader span:nth-of-type(2) {
-webkit-animation-delay: 0.3s;
-moz-animation-delay: 0.3s;
}
.loader span:nth-of-type(3) {
-webkit-animation-delay: 0.6s;
-moz-animation-delay: 0.6s;
}
#-webkit-keyframes loader {
0% {
width: 10px;
height: 10px;
opacity: 0.9;
-webkit-transform: translateY(0);
}
100% {
width: 24px;
height: 24px;
opacity: 0.1;
-webkit-transform: translateY(-21px);
}
}
#-moz-keyframes loader {
0% {
width: 10px;
height: 10px;
opacity: 0.9;
-moz-transform: translateY(0);
}
100% {
width: 24px;
height: 24px;
opacity: 0.1;
-moz-transform: translateY(-21px);
}
}
<div class="loader" style="height:100px;">
<span></span>
<span></span>
<span></span>
</div>
<br />
<div>
<button id="popupArea">Click here to invoke a popup window</button>
</div>
Try to put height at loader's div .
.loader {
text-align: center;
height:85px;
}
http://jsfiddle.net/csdtesting/9emc9so9/4/
Simple, just set the height for the span
Set height: 100px; in the loader
.loader {
text-align: center;
height:100px;
}
Here is a DEMO
I've been struggling with this for the past few days, so help would be greatly appreciated. I have a Title with a line (hr element) right below it. I'm trying to have a div centered in the hr that grows and shrinks. However, when the css3 animation is applied it causes the div to be displaced down and to the right, as if the div's top-left point (which I think is (0,0)) is set to be where the middle was.
I've created a jsfiddle to illustrate what I mean.
Here's my html:
<div id="header">
<h1>Center</h1>
<div id="action-bar">
<hr class="center-line" />
<div class="circle animation"></div>
</div>
</div>
and my css:
div#header {
color: #000;
width: 90%;
text-align: center;
position:absolute;
top:50%;
left:50%;
transform: translate(-50%, -50%);
}
div#header h1 {
font-size: 50px;
font-weight: 300;
margin-top: 0px;
margin-bottom: 0px;
}
/* the line beneath h1 */
div #action-bar {
margin: 25px 0;
position: relative;
}
div.circle {
width: 1em;
height: 1em;
background: #000;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
position: absolute;
}
div.circle:hover {
width: 2em;
height: 2em;
background: #000;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
position: absolute;
}
hr.center-line {
border: 0;
height: .25em;
background: #000;
}
/* animation */
#keyframes pulse {
0% {
transform: rotate(0deg);
}
50% {
transform: rotate(90deg);
}
100% {
transform: rotate(180deg);
}
}
#-webkit-keyframes pulse {
0% {
transform: rotate(0deg);
}
50% {
transform: rotate(90deg);
}
100% {
transform: rotate(180deg);
}
}
.animation {
animation: pulse 2s ease-in-out 0s infinite normal none;
-webkit-animation: pulse 2s ease-in-out 0s infinite normal none;
-webkit-backface-visibility: hidden;
}
Can anybody point be in the right direction? I'm looking for a pure-css solution if possible. Thanks!
Add negative margin to your circle element, half of it's width and height:
div.circle {
width: 1em;
height: 1em;
background: #000;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
position: absolute;
margin-left: -0.5em;
margin-top: -0.5em;
}
div.circle:hover {
width: 2em;
height: 2em;
margin-left: -1em;
margin-top: -1em;
}
jsFiddle Demo.
Here is a smooth pulsing option.
http://jsfiddle.net/aLjsut5r/4/
/* animation */
#keyframes pulse {
0% {
transform: scale(1);
}
50% {
transform: scale(.8);
}
100% {
transform: scale(1);
}
}
#-webkit-keyframes pulse {
0% {
transform: scale(1);
}
50% {
transform: scale(.8);
}
100% {
transform: scale(1);
}
}
.animation {
animation: pulse 2s ease-in-out 0s infinite normal none;
-webkit-animation: pulse 2s ease-in-out 0s infinite normal none;
-webkit-backface-visibility: hidden;
}
.pulsing {
border: 3px solid #999;
-webkit-border-radius: 30px;
height: 18px;
width: 18px;
position: absolute;
left:20px;
top:214px;
-webkit-animation: pulsate 1s ease-out;
-webkit-animation-iteration-count: infinite;
opacity: 0.0;
}
#-webkit-keyframes pulsate {
0% {-webkit-transform: scale(0.5, 0.5); opacity: 0.5;}
50% {opacity: 1.0;}
100% {-webkit-transform: scale(1.2, 1.2); opacity: 0.5;}
}