I have an image gallery set up. It transitions to the next photo like a slideshow. I am trying to figure out how to get the images to fade as the slideshow is transitioning to the next image. I've tried to add transitions and opacity but can't seem to get it right. Thanks for the help!
body {
padding: 0;
margin: 0;
}
.slider-frame {
padding: 0;
overflow: hidden;
height: 800px;
width: 1200px;
margin-left: auto;
margin-right: auto;
}
#keyframes slide_animation {
0% {
left: 0px;
}
10% {
left: 0px;
}
20% {
left: 1200px;
}
30% {
left: 1200px;
}
40% {
left: 2400px;
}
50% {
left: 2400px;
}
60% {
left: 1200px;
}
70% {
left: 1200px;
}
80% {
left: 0px;
}
90% {
left: 0px;
}
100% {
left: 0px;
}
}
.slide-images {
width: auto;
height: auto;
margin: 0 0 0 -2400px;
position: relative;
-webkit-animation-name: slide_animation;
animation-name: slide_animation;
-webkit-animation-duration: 33s;
animation-duration: 33s;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
-webkit-animation-direction: alternate;
animation-direction: alternate;
-webkit-animation-play-state: running;
animation-play-state: running;
}
.img-container {
height: 800px;
width: 1200px;
margin-left: auto;
margin-right: auto;
position: relative;
float: left;
}
img {
width: 100%;
height: 100%;
margin-right: auto;
margin-left: auto;
padding-bottom: 100px;
padding-top: 100px;
padding-right: 100px;
padding-left: 100px;
}
<div class="slider-frame">
<div class="slide-images">
<div class="img-container">
<img src="../../assets/img/debug.jpg" alt="Angular Carousel 1">
</div>
<div class="img-container">
<img src="../../assets/img/actual.png" alt="Angular Carousel 1">
</div>
<div class="img-container">
<img src="../../assets/img/face.png" alt="Angular Carousel 1">
</div>
</div>
</div>
To give a fade in effect the below method can be used and you can alter it to your code.
.
fade-in {
animation: fadeIn ease 20s;
-webkit-animation: fadeIn ease 20s;
-moz-animation: fadeIn ease 20s;
-o-animation: fadeIn ease 20s;
-ms-animation: fadeIn ease 20s;
}
#keyframes fadeIn {
0% {opacity:0;}
100% {opacity:1;}
}
#-moz-keyframes fadeIn {
0% {opacity:0;}
100% {opacity:1;}
}
#-webkit-keyframes fadeIn {
0% {opacity:0;}
100% {opacity:1;}
}
#-o-keyframes fadeIn {
0% {opacity:0;}
100% {opacity:1;}
}
#-ms-keyframes fadeIn {
0% {opacity:0;}
100% {opacity:1;}
}
Related
I have a css background animation that separate the screen into 2 color part, div 1 left is black and div 2 right is white. However I want to make the div 2 right white part to become a image background while black part remain.
How do I insert the image cover into the right white part without affect the left black part
this is the example image cover I would like to cover in div 2
below is my code
body,
html {
margin: 0;
padding: 0;
}
.bg {
min-height: 100vh;
animation: BgAnimation;
-webkit-animation: BgAnimation;
-moz-animation: BgAnimation;
background: linear-gradient(106deg, #313131 50%, white 50.1%);
animation-duration: 1.3s;
animation-iteration-count: 1;
animation-fill-mode: forwards;
animation-timing-function: ease-in-out;
background-size: 200% 200%;
}
#keyframes BgAnimation {
0% {
background-position: 0% 0%;
}
100% {
background-position: 50% 50%;
}
}
#keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
#wrapper {
display: flex;
}
#left {
flex: 0 0 65%;
color: white;
margin-left: 10%;
margin-top: 20%;
animation: fadein 3s;
}
#right {
flex: 1;
margin-right: 5%;
margin-top: 20%;
font-size: 21px;
text-align: center;
animation: fadein 6s;
-moz-animation: fadein 6s; /* Firefox */
-webkit-animation: fadein 6s; /* Safari and Chrome */
-o-animation: fadein 6s;
}
<body>
<div class="bg">
<div id="wrapper">
<div id="left">1 div</div>
<div id="right">2 div</div>
</div>
</div>
</body>
make your gradient black/transparent and put the image below it:
body {
margin: 0;
}
.bg {
min-height: 100vh;
background:
linear-gradient(106deg, #313131 50%, transparent 50.1%),
url(https://i.stack.imgur.com/bPLa1m.jpg) right;
animation: BgAnimation 1.3s forwards;
background-size: 200% 200%,80% auto;
}
#keyframes BgAnimation {
0% {
background-position: 0% 0%,right;
}
100% {
background-position: 50% 50%,right;
}
}
#keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
#wrapper {
display: flex;
}
#left {
flex: 0 0 65%;
color: white;
margin-left: 10%;
margin-top: 20%;
animation: fadein 3s;
}
#right {
flex: 1;
margin-right: 5%;
margin-top: 20%;
font-size: 21px;
text-align: center;
animation: fadein 6s;
}
<div class="bg">
<div id="wrapper">
<div id="left">1 div</div>
<div id="right">2 div</div>
</div>
</div>
I have a png file of flags that I want to animate moving to the right side, off the screen then back onto the screen from the left side. Is there something in css that works for this specific purpose? or do I have to get creative with the design?
I have used keyframe animation to move the image from left to right so I can understand more about how animation works in css but I am still struggling.
<head>
<link rel="stylesheet" href="Ufatrue.css">
<title>Bashkorostan</title>
</head>
<body bgcolor="#E1E4E6">
<div id="Top">
<img src="Top.png" alt="7 Flags" align="middle">
</div>
<div id="Title">
<h>Volga Federal District News</h>
</div>
#Top {
position: relative;
animation: myanimation;
animation-duration: 8s;
animation-iteration-count: infinite;
}
#keyframes myanimation {
0% {left: -300px; top: 0px;}
25% {left: -300px; top: 0px;}
50% {left: 300px; top: 0px;}
75% {right: -300px; top: 0px;}
100% {right: 300px; top: 0px;}
}
You can use just marquee tag for HTML.
.box{
width:10em;
height:10em;
background:dodgerblue;
}
<marquee behavior="scroll" onmouseover="this.stop()" onmouseout="this.start()" direction="right" scrollamount="50" scrolldelay="1"><div class="box"></div></maruquee>
I am not sure i understand exactly what you want. But take a look at the snippet below and please comment in the comment section below and tell me if this is what you wanted
.wrapper {
overflow: hidden;
}
#top {
position: relative;
animation: myanimation;
animation-duration: 3s;
animation-iteration-count: infinite;
animation-timing-function: ease-in;
height: 100px;
width: 100px;
background: red;
}
#keyframes myanimation {
0% {
left: 0;
transform: translateX(-100%)
}
100% {
left: 100%;
transform: translateX(100%)
}
}
<div class="wrapper">
<div id="top">
</div>
</div>
What about this?: https://jsfiddle.net/wwWaldi/tadyh6p9/14/
#Top {
width: 30px;
height: 30px;
background: blue;
position: relative;
animation: myanimation;
animation-duration: 8s;
animation-iteration-count: infinite;
}
#keyframes myanimation {
0% { right: 0; }
25% { right: -120%; }
85% { visibility: hidden; }
90% {
left: -20%;
visibility: visible;
}
100% {
left: 0;
}
}
I've made a small Image animation where images changes opacity over time.It works smoothly but when last image gets to 100% it jumps straight to 0% without any transition.
I have already tried animation-direction: alternate for third image and delay for all image but it does not work for me. Delay works only first step of animation cycle after it delay becomes 0 for all.
Here is my CSS
.rightside .img-container img.first {
animation-name: first-image;
animation-duration: 9s;
animation-fill-mode: both;
animation-iteration-count: infinite;
/* animation-delay: -10s; */
}
.rightside .img-container img.second {
position: absolute;
top: 0;
animation-name: second-image;
animation-duration: 9s;
animation-fill-mode: both;
animation-iteration-count: infinite;
}
.rightside .img-container img.third {
position: absolute;
top: 0;
animation-name: final-image;
animation-duration: 9s;
animation-fill-mode: both;
animation-iteration-count: infinite;
animation-timing-function: linear;
/* animation-direction: alternate; */
}
#keyframes first-image {
0% {
opacity: 0;
}
33.3% {
opacity: 1;
}
67% {
opacity: 0;
}
100% {
opacity: 0;
}
}
#keyframes second-image {
0% {
opacity: 0;
}
33.3% {
opacity: 0;
}
67% {
opacity: 1;
}
100% {
opacity: 0;
}
}
#keyframes final-image {
0% {
opacity: 0;
}
33.3% {
opacity: 0;
}
67% {
opacity: 0;
}
100% {
opacity: 1;
}
}
HTML
<div class="img-container">
<img src="Images/Apple.png" class="first turn" alt="Image Here" />
<img src="Images/Bee.png" class="second" alt="Image Here" />
<img src="Images/Cat.png" class="third" alt="Image Here" />
</div>
The clasical aproach to this would be just using different delays:
div {
animation-name: all;
animation-duration: 9s;
animation-iteration-count: infinite;
width: 100px;
height: 100px;
background-color: yellow;
}
.first {
animation-delay: -3s;
background-color: lightgreen;
}
.third {
animation-delay: -6s;
background-color: lightblue;
}
#keyframes all {
0% {
opacity: 0;
}
33.3% {
opacity: 1;
}
67% {
opacity: 0;
}
100% {
opacity: 0;
}
}
<div class="first"></div>
<div class="second"></div>
<div class="third"></div>
I would like to use this image slider: http://codepen.io/rslglover/pen/DBvoA
The image slider works well, but when its finish, it stops. I can't see whats the difference is from the CodePen codes, and what I've done. How can it be it works in the CodePen link?
article{
position: absolute;
left: 450px;
background: #292929;
color: #e3e3e3;
width: 450px;
height: 450px;
text-align: center;
font: 2em/1em sans-serif;
border-box: box-sizing;
padding-top: 0px;
}
article:nth-of-type(1){
animation: slideIn 50s linear 0s infinite;
}
article:nth-of-type(2){
animation: slideIn 50s linear 5s infinite;
}
article:nth-of-type(3){
animation: slideIn 50s linear 10s infinite;
}
article:nth-of-type(4){
animation: slideIn 50s linear 15s infinite;
}
article:nth-of-type(5){
animation: slideIn 50s linear 20s infinite;
}
article:nth-of-type(6){
animation: slideIn 50s linear 25s infinite;
}
article:nth-of-type(7){
animation: slideIn 50s linear 30s infinite;
}
article:nth-of-type(8){
animation: slideIn 50s linear 35s infinite;
}
article:nth-of-type(9){
animation: slideIn 50s linear 40s infinite;
}
article:nth-of-type(10){
animation: slideIn 50s linear 45s infinite;
}
#keyframes slideIn{
0% {left: 450px;}
1% {left: 0;}
10% {left: 0;}
11% {left: -450px;}
100%{left: -450px;}
}
.galleryImg {
height: 450px;
width: 450px;
}
.gallery {
width: 450px;
height: 450px;
position: absolute;
left: 50%;
top: 50%;
margin-left: -225px;
margin-top: -225px;
overflow: hidden;
background: rgba(0,0,0,0.3);
border: 1px solid #fff;
box-shadow:5px 5px 5px 5px rgba(0,0,0,0.7);
}
And my html
<div class="galleryInfo">
<div class="gallery">
<article><img class="galleryImg" src="images/aa2.png" alt=""></article>
<article> <img class="galleryImg" src="images/aa1.png" alt=""></article>
<article><img class="galleryImg" src="images/bb1.png" alt=""></article>
<article><img class="galleryImg" src="images/bb2.png" alt=""></article>
</div>
</div>
Check this out:
HTML:
<div class="galleryInfo">
<div class="gallery">
<section>
<article><img src="https://image.freepik.com/free-icon/medical-samples-in-test-tubes-couple_318-61810.jpg" /></article>
<article><img src="https://image.freepik.com/free-icon/medical-samples-in-test-tubes-couple_318-61810.jpg" /></article>
<article><img src="https://image.freepik.com/free-icon/medical-samples-in-test-tubes-couple_318-61810.jpg" /></article>
<article><img src="https://image.freepik.com/free-icon/medical-samples-in-test-tubes-couple_318-61810.jpg" /></article>
</section>
</div>
</div>
CSS:
html{
background: #aaa;
}
section{
width: 200px;
height: 200px;
position: relative;
left: 50%;
top: 1em;
margin-left: -100px;
overflow: hidden;
background: #292929;
border: 10px solid #fff;
}
/*section:hover article{
animation-play-state: paused;
}*/
article{
position: absolute;
left: 450px;
background: #292929;
color: #e3e3e3;
width: 450px;
height: 450px;
text-align: center;
font: 2em/1em sans-serif;
border-box: box-sizing;
padding-top: 0px;
}
.galleryImg {
height: 450px;
width: 450px;
}
.gallery {
width: 450px;
height: 450px;
position: absolute;
left: 50%;
top: 50%;
margin-left: -225px;
margin-top: -225px;
overflow: hidden;
background: rgba(0,0,0,0.3);
border: 1px solid #fff;
box-shadow:5px 5px 5px 5px rgba(0,0,0,0.7);
}
article:nth-of-type(1){
animation: slideIn 20s linear 0s infinite;
}
article:nth-of-type(2){
animation: slideIn 20s linear 5s infinite;
}
article:nth-of-type(3){
animation: slideIn 20s linear 10s infinite;
}
article:nth-of-type(4){
animation: slideIn 20s linear 15s infinite;
}
#keyframes slideIn{
0% {left: 200px;}
1% {left: 0;}
10% {left: 0;}
11% {left: -200px;}
100%{left: -200px;}
}
Or change position in css file clas galleryInfo and gallery above animation.
The primary reason why your animation appears to stop, is because the CSS is structured for 10 slides.
To maintain the same duration and animation, the keyframes percentages need to be configured for the new total number of slides you are using.
#keyframes slideIn{
0% {left: 200px;} /* Always 0% */
2.5% {left: 0;} /* Equivalent of 0.5s e.g. 0.5/maxTime*100 */
25% {left: 0;} /* Equivalent of 5s e.g. 5/maxTime*100 */
27.5% {left: -200px;} /* Equivalent of 5.5s e.g. 5.5/maxTime*100 */
100%{left: -200px;} /* Always 100% */
}
By changing the keyframes, you will maintain the same slide speed as your codepen example had.
Here is a working snippet.
html{
background: #aaa;
}
section{
width: 200px;
height: 200px;
position: relative;
left: 50%;
top: 1em;
margin-left: -100px;
overflow: hidden;
background: #292929;
border: 10px solid #fff;
}
/*section:hover article{
animation-play-state: paused;
}*/
article{
position: absolute;
left: 200px;
background: #292929;
color: #e3e3e3;
width: 200px;
height: 200px;
text-align: center;
font: 2em/1em sans-serif;
border-box: box-sizing;
padding-top: 80px;
}
/*
* As each slide's animation is 5s, the set duration is totalSlides * 5.
*/
article:nth-of-type(1){
animation: slideIn 20s linear 0s infinite;
}
article:nth-of-type(2){
animation: slideIn 20s linear 5s infinite;
}
article:nth-of-type(3){
animation: slideIn 20s linear 10s infinite;
}
article:nth-of-type(4){
animation: slideIn 20s linear 15s infinite;
}
#keyframes slideIn{
0% {left: 200px;} /* Always 0% */
2.5% {left: 0;} /* Equivalent of 0.5s e.g. 0.5/maxTime*100 */
25% {left: 0;} /* Equivalent of 5s e.g. 5/maxTime*100 */
27.5% {left: -200px;} /* Equivalent of 5.5s e.g. 5.5/maxTime*100 */
100%{left: -200px;} /* Always 100% */
}
<section>
<article>Slide 1</article>
<article>Slide 2</article>
<article>Slide 3</article>
<article>Slide 4</article>
</section>
.car {
background: url('cartemplate orange 1.png');
width: 444px;
height: 150px;
}
.carleft {
-webkit-animation: moveLeft 3s;
-webkit-animation-delay:2s;
-webkit-animation-iteration-count: infinite;
-moz-animation: moveLeft 3s;
-moz-animation-iteration-count: infinite;
-ms-animation: moveLeft 3s;
-ms-animation-iteration-count: infinite;
-o-animation: moveLeft 3s;
-o-animation-iteration-count: infinite;
animation: moveLeft 3s;
animation-iteration-count: infinite;
}
#-webkit-keyframes moveLeft
{
0% { right: -500px; }
50% { right: 700px; }
100% { right: 2000px; }
}
#-moz-keyframes moveLeft
{
0% { right: -500px; }
50% { right: 700px; }
100% { right: 2000px; }
}
#-ms-keyframes moveLeft
{
0% { right: -500px; }
50% { right: 700px; }
100% { right: 2000px; }
}
#keyframes moveLeft
{
0% { right: -500px; }
50% { right: 700px; }
100% { right: 2000px; }
}
.carright {
-webkit-animation: moveRight 3s;
-webkit-animation-delay:2s;
-webkit-animation-iteration-count: infinite;
-moz-animation: moveRight 3s;
-moz-animation-iteration-count: infinite;
-ms-animation: moveRight 3s;
-ms-animation-iteration-count: infinite;
-o-animation: moveRight 3s;
-o-animation-iteration-count: infinite;
animation: moveRight 3s;
animation-iteration-count: infinite;
}
#-webkit-keyframes moveRight
{
0% { left: -500px; }
50% { left: 700px; }
100% { left: 2000px; }
}
#-moz-keyframes moveRight
{
0% { left: -500px; }
50% { left: 700px; }
100% { left: 2000px; }
}
#-ms-keyframes moveRight
{
0% { left: -500px; }
50% { left: 700px; }
100% { left: 2000px; }
}
#keyframes moveRight
{
0% { left: -500px; }
50% { left: 700px; }
100% { left: 2000px; }
}
.wheel {
width: 50px !important;
height: 50px !important;
position: relative;
}
.wheel1 {
width: 100%;
height: 100%;
background-color: #3D3D3D;
border-radius: 50% / 50%;
position: absolute;
}
.wheel2 {
width: 70%;
height: 70%;
background-color: #B8B8B8;
margin: 10%;
border-radius: 50% / 50%;
position: absolute;
-webkit-animation: wheelActive 800ms;
-webkit-animation-iteration-count: infinite;
-moz-animation: wheelActive 800ms;
-moz-animation-iteration-count: infinite;
-ms-animation: wheelActive 800ms;
-ms-animation-iteration-count: infinite;
-o-animation: wheelActive 800ms;
-o-animation-iteration-count: infinite;
animation: wheelActive 800ms;
animation-iteration-count: infinite;
}
#-webkit-keyframes wheelActive
{
0% { margin: 15%; height: 70%; width: 70%; }
50% { margin: 5%; height: 90%; width: 90%; }
100% { margin: 15%; height: 70%; width: 70%; }
}
#-moz-keyframes wheelActive
{
0% { margin: 15%; height: 70%; width: 70%; }
50% { margin: 5%; height: 90%; width: 90%; }
100% { margin: 15%; height: 70%; width: 70%; }
}
#-ms-keyframes wheelActive
{
0% { margin: 15%; height: 70%; width: 70%; }
50% { margin: 5%; height: 90%; width: 90%; }
100% { margin: 15%; height: 70%; width: 70%; }
}
#keyframes wheelActive
{
0% { margin: 15%; height: 70%; width: 70%; }
50% { margin: 5%; height: 90%; width: 90%; }
100% { margin: 15%; height: 70%; width: 70%; }
}
.wheelleft, .wheelright {
position: absolute;
}
.carleft .wheelleft {
top: 135px;
left: 53px;
}
.carleft .wheelright {
top: 135px;
left: 348px;
}
.carright .wheelleft {
top: 135px;
left: 64px;
}
.carright .wheelright {
top: 135px;
left: 358px;
}
<div class="car carleft">
<div class="wheel wheelleft">
<div class="wheel1"></div>
<div class="wheel2"></div>
</div>
<div class="wheel wheelright">
<div class="wheel1"></div>
<div class="wheel2"></div>
</div>
</div>
jsFiddle: http://jsfiddle.net/c6kBj/
I'm trying to make a car in CSS3 that goes from left to right and also some cars that go from right to left, with different colors and everything fancy. But it isn't working. The wheels are working correctly, but the car is not moving from left to right. Why not?
you are missing position: absolute; on your .car div - without that, .right is meaningless as all elements default to position: static;
.car {
background: url('cartemplate orange 1.png');
width: 444px;
height: 150px;
position: absolute;
}
http://jsfiddle.net/c6kBj/1/
You should actually be using translate(0,0) to move stuff around (performs better than animated position values)