CSS animte background image issue in html5 - css

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

Related

CSS animation: center absolute div diagonally

I have 4 square divs absolute positioned in each corner on the page. I need to animate them to ease into the center to form a circle. I am having a rough time trying to figure out how you would move them diagonally to the center. I have the code below for my html and css. So far I have them all the colors they are suppose to be and I have them set to transition with ease into a border-radius of 50% for one side on each. That way when they move diagonally to the center they can join together to eventually form into a circle. The main issue is just figuring out how to have them ease diagonally into the center. (I am only aloud to use css for this.)I also have what I have tried to accomplish this with in comments in the css code.
<body>
<div class="square_one"></div>
<div class="square_two"></div>
<div class="square_three"></div>
<div class="square_four"></div>
</body>
CSS
/* Layout */
div {
width: 100px;
height: 100px;
animation-name: squareCircle;
animation-duration: 5s;
animation-delay: 1s;
/* animation-iteration-count: infinite; */
transition: background-color 5s ease;
}
#keyframes squareCircle {
to {
background-color: black;
}
}
.square_one {
position: absolute;
top: 0;
left: 0;
animation-name: squareOne;
animation-duration: 5s;
animation-delay: 0.5s;
transition: border-bottom-right ease 4s;
/* transition: translate 4s; */
/* transform: translate(-50%,-50%); */
}
#keyframes squareOne {
to {
border-bottom-right-radius: 50%;
/* transform: translate(-50%,-50%); */
}
}
.square_two {
position: absolute;
top: 0;
right: 0%;
animation-name: squareTwo;
animation-duration: 5s;
animation-delay: 0.5s;
transition: border-bottom-left ease 0.5s;
}
#keyframes squareTwo {
to {
border-bottom-left-radius: 50%;
}
}
.square_three {
position: absolute;
bottom: 0%;
left: 0;
animation-name: squareThree;
animation-duration: 5s;
animation-delay: 0.5s;
transition: border-top-right ease 0.5s;
}
#keyframes squareThree {
to {
border-top-right-radius: 50%;
}
}
.square_four {
position: absolute;
bottom: 0%;
right: 0%;
animation-name: squareFour;
animation-duration: 5s;
animation-delay: 0.5s;
transition: border-top-left-radius ease 5s;
}
#keyframes squareFour {
to {
border-top-left-radius: 50%;
}
}
/* Block */
.square_one {
background-color: lightcoral;
}
.square_two {
background-color: lightblue;
}
.square_three {
background-color: lightgreen;
}
.square_four {
background-color: lightgoldenrodyellow;
}
Is this what you are looking to accomplish? :)
div {
width: 100px;
height: 100px;
animation-name: squareCircle;
animation-duration: 5s;
animation-fill-mode: forwards;
animation-delay: 1s;
/* animation-iteration-count: infinite; */
transition: background-color 5s ease;
}
#keyframes squareCircle {
to {
background-color: black;
}
}
.square_one {
position: absolute;
top: 0;
left: 0;
animation-name: squareOne;
animation-duration: 5s;
animation-delay: 0.5s;
transition: border-bottom-right, top, left ease 4s;
/* transition: translate 4s; */
}
#keyframes squareOne {
to {
border-bottom-right-radius: 100%;
top: 50%;
left: 50%;
/* transform: translate(-50%,-50%); */
}
}
.square_two {
position: absolute;
top: 0;
right: 0%;
animation-name: squareTwo;
animation-duration: 5s;
animation-delay: 0.5s;
transition: border-bottom-left, top, right ease 0.5s;
}
#keyframes squareTwo {
to {
border-bottom-left-radius: 100%;
top: 50%;
right: 50%;
}
}
.square_three {
position: absolute;
bottom: 0%;
left: 0;
animation-name: squareThree;
animation-duration: 5s;
animation-delay: 0.5s;
transition: border-top-right, bottom, left ease 0.5s;
}
#keyframes squareThree {
to {
bottom: 50%;
left: 50%;
border-top-right-radius: 100%;
}
}
.square_four {
position: absolute;
bottom: 0%;
right: 0%;
animation-name: squareFour;
animation-duration: 5s;
animation-delay: 0.5s;
transition: border-top-left-radius, bottom, right ease 5s;
}
#keyframes squareFour {
to {
bottom: 50%;
right: 50%;
border-top-left-radius: 100%;
}
}
/* Block */
.square_one {
background-color: lightcoral;
}
.square_two {
background-color: lightblue;
}
.square_three {
background-color: lightgreen;
}
.square_four {
background-color: lightgoldenrodyellow;
}
<body>
<div class="square_one"></div>
<div class="square_two"></div>
<div class="square_three"></div>
<div class="square_four"></div>
</body>
This is the CSS I wound up with to get the results I needed. Hopefully we are/were able to help anyone with the same or similar issue now or even in the future.
/*Universal*/
.square_one,
.square_two,
.square_three,
.square_four {
height: 100px;
width: 100px;
}
.square_one:hover,
.square_two:hover,
.square_three:hover,
.square_four:hover {
transition: border 0.25s linear;
border: 2px solid white;
}
/*Individual*/
.square_one {
position: absolute;
top: 0;
left: 0;
background: coral;
animation: circle1 3s linear 1 forwards;
}
.square_two {
position: absolute;
top: 0;
right: 0;
background: lightblue;
animation: circle2 3s linear 1 forwards;
}
.square_three {
position: absolute;
left: 0;
bottom: 0;
background: lightgreen;
animation: circle3 3s linear 1 forwards;
}
.square_four {
position: absolute;
right: 0;
bottom: 0;
background: lightgoldenrodyellow;
animation: circle4 3s linear 1 forwards;
}
/*Animation*/
#keyframes circle1 {
0% {
position: absolute;
}
100% {
position: fixed;
top: 50%;
left: 50%;
background: black;
border-radius: 0 0 100px 0;
}
}
#keyframes circle2 {
0% {
position: absolute;
}
100% {
position: fixed;
top: 50%;
right: 50%;
background: black;
border-radius: 0 0 0 100px;
}
}
#keyframes circle3 {
0% {
position: absolute;
}
100% {
position: fixed;
bottom: 50%;
left: 50%;
background: black;
border-radius: 0 100px 0 0;
}
}
#keyframes circle4 {
0% {
position: absolute;
}
100% {
position: fixed;
bottom: 50%;
right: 50%;
background: black;
border-radius: 100px 0 0 0;
}
}

CSS animation, FadeIn / FadeOut 2 images continuously

I have created sample
CodePen here.
I tried below but didn't work.
.elementToFadeInAndOut {
width:200px;
height: 200px;
background: red;
-webkit-animation: fadeinout 4s linear forwards;
animation: fadeinout 4s linear forwards;
}
#-webkit-keyframes fadeinout {
0%,100% { opacity: 0; }
50% { opacity: 1; }
}
#keyframes fadeinout {
0%,100% { opacity: 0; }
50% { opacity: 1; }
}
As you will see this sample has 3 images. I give them id = "imge1", "imge2", "imge3"
img3 keeps rotating using keyframe.
I need to show img1 and img2 showing kinda fadein-fadeout effect.
so when img3 rotates to bottom that time may be fadeout img1 and fadeIn img2. (or other way around is fine)
basically 2 images should keep replacing with some fade effect and img3 keeps rotating.
Here is a link I tried but could not achieve solution.
CSS animation, fade in fade out opacity on automated slideshow
CSS how to make an element fade in and then fade out?
also, this needs to be done using pure-css only. I have to put this in nextjs project.
Thanks
You need animation-delay and animation-iteration-count to achieve that
*{
box-sizing: border-box;
padding: 0;
margin: 0;
}
figure{
width: 100vw;
height: 50vh;
position: relative;
background: green;
text-align: center;
}
picture{
position: relative;
display: inline-block;
width: 25%;
}
picture img{
width: 100%
}
picture:not(:last-of-type){opacity: 0}
picture:first-of-type{
background: red;
animation: fadeinout 4s linear forwards infinite;
}
picture:nth-child(2){
background: red;
animation: fadeinout 4s 2s linear forwards infinite;/*you need to add the delay here*/
}
picture:last-of-type{
animation: spin 4s linear infinite;
}
figcaption{
position: absolute;
bottom: 0;
left:0;
width: 100%;
}
#keyframes fadeinout {
50% { opacity: 1; }
}
#keyframes spin {
to { transform: rotate(360deg);}
}
<figure>
<picture>img1</picture>
<picture>img2</picture>
<picture>
<img class="img3" src="https://anima-uploads.s3.amazonaws.com/projects/5e81f9028ef92977fa0913c0/releases/5e81f928d7217864bf001225/img/login-radar-1.png" alt="img" />
</picture>
<figcaption>Css Labs</figcaption>
</figure>
See below. I added a background color to the third image to make it visible.
#img3 {
background-color: red; /* to make it visible */
}
.flexDisplay {
display: flex;
}
.wrapper {
display: flex;
justify-content: space-evenly;
}
.loginImage {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
#keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.img1 {
animation: spin 3s linear infinite;
opacity: 0.1;
width: 200px;
height: 200px;
align-items: center;
}
.elementToFadeInAndOut {
width: 200px;
height: 200px;
background: red;
animation: fadeinout 4s linear infinite;
}
#keyframes fadeinout {
0%,
100% {
opacity: 0;
}
50% {
opacity: 1;
}
}
<div class="flexDisplay">
<div class="wrapper">
<img id="img1" class="elementToFadeInAndOut" src="https://anima-uploads.s3.amazonaws.com/projects/5e81f9028ef92977fa0913c0/releases/5e81fc3f75aec5860f52b6a0/img/loginsuper-rectangle-copy.png " class="loginImage" alt="branding logo" />
<img id="img2" class="elementToFadeInAndOut" src="https://anima-uploads.s3.amazonaws.com/projects/5e81f9028ef92977fa0913c0/releases/5e81fc3f75aec5860f52b6a0/img/loginsuper-rectangle.png" class="loginImage elementToFadeInAndOut" alt="branding logo" />
<img id="img3" class="img1" src="https://anima-uploads.s3.amazonaws.com/projects/5e81f9028ef92977fa0913c0/releases/5e81f928d7217864bf001225/img/login-radar-1.png" alt="img" />
</div>
</div>
Basically, you need to apply 2 different animation functions to the different elements.
I have used z-index to let the images overlap each other and
set the infinite property for the duration of your animation.
You can set an interval for your images using animation-delay.
.flexDisplay{
display: flex;
background: #f1f1f1;
}
.wrapper{
display: flex
}
.img1{
z-index:3;
}
.loginImage1{
width: 100%;
height: 100%;
position:absolute;
left:0;
top:0;
z-index:1;
}
.loginImage2{
width: 100%;
height: 100%;
position:absolute;
left:0;
top:0;
z-index:2;
}
#keyframes spin {
from {
transform:rotate(0deg);
}
to {
transform:rotate(360deg);
}
}
.img1{
animation: spin 3s linear infinite;
width: 200px;
height: 200px;
align-items: center;
}
.img2{
position: relative;
width: 200px;
height: 200px;
}
.elementToFadeInAndOut1 {
width:200px;
height: 200px;
background: red;
-webkit-animation: fadeinout 4s linear infinite;
animation: fadeinout 4s linear infinite;
}
#-webkit-keyframes fadeinout {
0%,100% {
opacity: 0;
}
50% {
opacity: 1;
}
}
#keyframes fadeinout {
0%,100% {
opacity: 0;
}
50% {
opacity: 1;
}
}
.elementToFadeInAndOut2 {
width:200px;
height: 200px;
background: red;
-webkit-animation: fadeinout 4s linear infinite;
animation: fadeinout 4s linear infinite;
animation-delay:5s;
}
#-webkit-keyframes fadeinout1 {
0%,100% {
opacity: 0;
}
50% {
opacity: 1;
}
}
#keyframes fadeinout1 {
0%,100% {
opacity: 0;
}
50% {
opacity: 1;
}
}
Created this pen: https://codepen.io/spaceCadett/pen/wvKKowL

Transition: rotate not working in Safari

I have a loading page while the website is loading. It works fine in Chrome but I need to fix it on Safari because it's not working. Here's my code:
.se-pre-con {
position: fixed;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
z-index: 9999;
background-color: #fff;
}
.loading {
top: 30%;
right: 45%;
position: fixed;
-webkit-animation: spinHorizontal 4s linear infinite;
-moz-animation: spinHorizontal 4s linear infinite;
animation: spinHorizontal 4s linear infinite;
}
#keyframes spinHorizontal {
0% {
transform: rotateY(0deg);
}
100% {
transform: rotateY(360deg);
}
}
<div class="se-pre-con">
<div class="loading">
<img src="http://www.pngmart.com/files/4/Circle-PNG-Picture-279x279.png">
</div>
It appears it has to do with the position: fixed on the .se-pre-con element. Try using absolute positioning or positioning it in another way.
.se-pre-con {
left: 0px;
top: 0px;
width: 100%;
height: 100%;
z-index: 9999;
background-color: #ffffff;
}
.loading {
width: 279px;
height: 279px;
top: 30%;
right: 45%;
position: fixed;
-webkit-backface-visibility: visible;
-webkit-animation: spinHorizontal 2s linear infinite;
-moz-animation: spinHorizontal 2s linear infinite;
animation: spinHorizontal 2s linear infinite;
background-color: transparent;
}
#keyframes spinHorizontal {
0% {
-webkit-transform: rotateY(0deg);
transform: rotateY(0deg);
}
100% {
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
}
}
<div class="se-pre-con">
<div class="loading">
<img src="http://www.pngmart.com/files/4/Circle-PNG-Picture-279x279.png" />
</div>
</div>

Transition from one image to another

currently I'm using this code:
#div { background-image: url('imageurl.com'), url('imageurl2.com'); position: absolute !important; right: 0; left: 0; height: 210px !important; display: table-cell !important; vertical-align: middle !important;}
#keyframes FadeInOut {
0% {
opacity:1;
}
45% {
opacity:1;
}
55% {
opacity:0;
}
100% {
opacity:0;
}
}
#div img.top {
animation-name: FadeInOut;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
animation-duration: 10s;
animation-direction: alternate;
}
I'm actually trying to implement the code from Demo 3 on this website:
http://css3.bradshawenterprises.com/cfimg/
In that demo, there are two images in one div and the code is just fading the first one in and out on a timer. I tried implementing this myself using the above code, but it's fading anything in and out. Does anyone know what I'm missing?
If you need implementation through background-image you can use pseudo-element:
#cf2 {
position:relative;
height:281px;
width:450px;
margin:0 auto;
background-image: url("http://css3.bradshawenterprises.com/images/Windows%20Logo.jpg");
}
#cf2::after{
content: ' ';
display: block;
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 1;
background-image: url("http://css3.bradshawenterprises.com/images/Turtle.jpg");
background-repeat: no-repeat;
background-position: 50% 0;
background-size: cover;
}
#keyframes cf3FadeInOut {
0% {
opacity:1;
}
45% {
opacity:1;
}
55% {
opacity:0;
}
100% {
opacity:0;
}
}
#cf2::after {
animation-name: cf3FadeInOut;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
animation-duration: 10s;
animation-direction: alternate;
}
<div id="cf2">
</div>
here's the implementation, they use separate <img> tags to show/hide images:
they are absolutely positioned one above the other, that one which is on top is just showing and hiding by the animation (which changes its opacity) - so the bottom one just becomes visible when top one has opacity = 0
#keyframes cf3FadeInOut {
0% {
opacity: 1;
}
45% {
opacity: 1;
}
55% {
opacity: 0;
}
100% {
opacity: 0;
}
}
#cf3 img.top {
animation-name: cf3FadeInOut;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
animation-duration: 10s;
animation-direction: alternate;
}
#cf3 img {
position: absolute;
left: 0;
}
#cf3 {
position: relative;
height: 281px;
width: 450px;
margin: 0 auto;
}
<div id="cf3" class="shadow">
<img class="bottom" src="http://css3.bradshawenterprises.com/images/Turtle.jpg">
<img class="top" src="http://css3.bradshawenterprises.com/images/Windows%20Logo.jpg">
</div>

Hidding an element as alternative to animation

I have the following CSS Plunker Example:
#-webkit-keyframes ngdialog-fadeout {
0% {opacity: 1;}
100% {opacity: 0; }
}
#keyframes ngdialog-fadeout {
0% {opacity: 1;}
100% {opacity: 0; }
}
.ngdialog.ngdialog-closing .ngdialog-overlay {
-webkit-backface-visibility: hidden;
-webkit-animation: ngdialog-fadeout 0.5s;
animation: ngdialog-fadeout 0.5s;
}
.ngdialog.ngdialog-closing .ngdialog-content {
-webkit-backface-visibility: hidden;
-webkit-animation: ngdialog-fadeout 0.5s;
animation: ngdialog-fadeout 0.5s;
}
I do not want to use animation. So I tried the following:
.ngdialog.ngdialog-closing .ngdialog-overlay {
visibility: hidden;
}
.ngdialog.ngdialog-closing .ngdialog-content {
visibility: hidden;
}
I am able to hide it but after doing it every link on the page is non reactive like something is over it ...
What am I missing?
UPDATE
I tried the following:
.ngdialog {
bottom: 0;
left: 0;
overflow: auto;
position: fixed;
right: 0;
top: 0;
z-index: 10000;
-webkit-overflow-scrolling: touch;
}
.ngdialog-overlay {
background-color: black;
bottom: 0;
left: 0;
position: fixed;
right: 0;
top: 0;
opacity: 0.6;
z-index: 100000;
}
.ngdialog.ngdialog-closing .ngdialog-overlay {
opacity: 0;
visibility: hidden;
}
.ngdialog-content {
background: white;
}
.ngdialog.ngdialog-closing .ngdialog-content {
opacity: 0;
visibility: hidden;
}
The same problem happens ...
Best way that I could find to "disable" animations from ngDialog is actually to speed them up so that they won't be visible anymore.
.ngdialog * {
-webkit-animation-duration: 0.01s !important;
-moz-animation-duration: 0.01s !important;
-o-animation-duration: 0.01s !important;
-ms-animation-duration: 0.01s !important;
animation-duration: 0.01s !important;
}

Resources