I want to create an animation in HTML, CSS where 3 images will be on each other. At that time there is a text says car and then all images will be separate and each image has text bottom of them saying body, tyres, engine. Any resource or how to do this type of animation?
I hope this will explain what I'm looking for.
.container {
position: absolute;
margin-left: auto;
margin-right: auto;
top: 0;
left: 45%;
height: 200px;
width: 200px;
}
.image-1 {
position: absolute;
top: 0;
left: 0;
margin-left: auto;
margin-right: auto;
width: 100%;
height: 100%;
animation: moveltf 1s ease-in-out;
}
.image-2 {
position: absolute;
top: 0;
left: 0;
margin-left: auto;
margin-right: auto;
width: 100%;
height: 100%;
}
.image-3 {
position: absolute;
top: 0;
left: 0;
margin-left: auto;
margin-right: auto;
width: 100%;
height: 100%;
animation: movertf 1s ease-in-out;
}
.image-1 {
animation-direction: normal;
animation-delay: 2s;
}
.image-3 {
animation-direction: reverse;
animation-delay: 2s;
}
#keyframes moveltf {
0% {
top: 0;
left: 0;
}
100% {
left: 100%;
}
}
#keyframes movertf {
0% {
top: 0;
left: 0;
}
100% {
right: 100%;
}
}
<div class="container">
<div class="image-1">
<img src="https://via.placeholder.com/50">
<p class="text">Image 1 </p>
</div>
<div class="image-2">
<img src="https://via.placeholder.com/50/ffff00">
<p class="text">Image 2</p>
</div>
<div class="image-3">
<img src="https://via.placeholder.com/50/ff00ff">
<p class="text">Image 3</p>
</div>
</div>
Related
I'm working on an animation with css and html but my animation isn't working.
https://www.abroprojectafbouw.nl/
Here is an example how it should look if its done (you need to scroll down) and here is my code. The black screen is always jumping back. Thank you for Help!
html,
body {
height: 100vh;
}
body {
margin: 0;
width: 100%;
}
.image {
animation: change 0.5s ease-out;
height: 70vw;
}
.img {
background-image: url("https://www.abroprojectafbouw.nl/wp-content/uploads/moddit-fly-images/468/foto-15-scaled-770x500-c.jpg");
background-size: cover;
position: relative;
width: 100%;
height: 70vw;
}
.overlay {
position: absolute;
width: 100%;
height: 70vw;
background-color: #000;
top: 0;
right: 0;
animation: slide 0.5s ease-out;
animation-delay: 0.6s;
}
#keyframes slide {
0% {
left: 0;
}
100% {
left: 100%;
}
}
#keyframes change {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
<div class="image">
<div class="img">
<div class="overlay"></div>
</div>
</div>
Add overflow: hidden to .img and forwards to slide animation.
html,
body {
height: 100vh;
}
body {
margin: 0;
width: 100%;
}
.image {
animation: change 0.5s ease-out;
height: 70vw;
}
.img {
background-image: url("https://www.abroprojectafbouw.nl/wp-content/uploads/moddit-fly-images/468/foto-15-scaled-770x500-c.jpg");
background-size: cover;
position: relative;
width: 100%;
height: 70vw;
overflow: hidden;
}
.overlay {
position: absolute;
width: 100%;
height: 70vw;
background-color: #000;
top: 0;
right: 0;
animation: slide 0.5s ease-out forwards;
animation-delay: 0.6s;
}
#keyframes slide {
0% {
left: 0;
}
100% {
left: 100%;
}
}
#keyframes change {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
<div class="image">
<div class="img">
<div class="overlay"></div>
</div>
</div>
CODE MUST BE VIEWED IN PORTRAIT MODE ON A MOBILE DEVICE TO REPLICATE THE ISSUE
Example of the issue: https://imgur.com/a/aaGnb1m
I have a horizontally scrolling container with images and below these images I have information about them as well as a buy button (I've removed the buy button and reduced this information in the example to only include 'TITLE' to simplify debugging). I've used CSS to animate the margin-left of the first image which essentially creates an effect where it flys through all the images and lands on the first one. By using developer mode on Safari / Chrome / Firefox etc. to test the code on portrait orientations, it has worked exactly as it should. The problem is, for some reason when I upload the page to my server and view the site on a mobile device like an iPhone for example, as soon as the animation begins, all of the information below the images vanishes. I'm not able to replicate this on a computer using developer mode / responsive design modes because it is only occurring on real mobile devices... extremely strange, I've never heard of anything like it nor have I been able to find any articles on it.
It may seem that an easy solution would be to simply create a separate fixed positioned div to house the information below the images, but this is not an option because I need the information to be positioned relative to the images based on the images' responsive widths and corresponding heights. Since it does work correctly using responsive design mode on a computer in portrait orientation, I would imagine that it should be possible to also work correctly on real mobile devices.
ALSO I've tried this on my phone both on the mobile Chrome app and on Safari, the information vanishes on both.
TO CLARIFY, the information should be not shown when the device is in landscape mode. The issue is not that the information disappears on mobile devices in landscape mode, the problem is that it disappears on mobile devices while they are in portrait mode... making this issue quite confusing because the disappearance is not being reproduced when tested on computers using a responsive design mode.
UPDATE It appears this issue is only happening on apple devices...
Here is the JSFiddle featuring the code (keep in mind that the issue is not occurring on computers though): https://jsfiddle.net/ob7fmvdc/
Here is the code:
<body>
<div id="horizontalproductcontainer">
<div id="mobilewrapperpleaseworkimsosickofcodingihavenoideawhatimdoinglol">
<div id="scrolling-wrapper">
<div class="productcardfirst">
<img src="images/.jpg" alt="." class="productimage1" />
</div>
<div class="productcard">
<img src="images/.jpg" alt="." class="productimage1" />
</div>
<div class="productcardlast">
<img src="images/.jpg" alt="." class="productimage1" />
</div>
<div class="productcardlastmobile">
<img src="images/.jpg" alt="." class="productimage1" />
</div>
<div class="productcardtext">
<img src="images/.jpg" alt="." class="productimage1" />
</div>
<div class="pricecontainermobile">
<h1>TITLE</h1>
</div>
</div>
</div>
</div>
</body>
body {
background: black;
}
.pricecontainermobile {
display: none;
}
#horizontalproductcontainer {
z-index: 0;
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
width: 100%;
height: 100%;
display: flex;
align-items: center;
}
#mobilewrapperpleaseworkimsosickofcodingihavenoideawhatimdoinglol {
z-index: 0;
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
width: 100%;
height: 100%;
display: flex;
align-items: center;
}
#scrolling-wrapper {
overflow-x: auto;
overflow-y: hidden;
white-space: nowrap;
text-align: center;
margin: 0 auto;
height: 100%;
width: 100%;
-webkit-overflow-scrolling: touch;
-ms-overflow-style: none;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.productcardfirst {
display: inline-block;
position: relative;
height: 60%;
width: 40%;
top: 50.6%;
transform: translateY(-50%);
animation-name: productslide;
animation-duration: 1.1s;
animation-delay: .5s;
animation-timing-function: ease-in-out;
animation-fill-mode: both;
-webkit-animation-name: productslide;
-webkit-animation-duration: 1.1s;
-webkit-animation-delay: .5s;
-webkit-animation-timing-function: ease-in-out;
-webkit-animation-fill-mode: both;
-moz-animation-name: productslide;
-moz-animation-duration: 1.1s;
-moz-animation-delay: .5s;
-moz-animation-timing-function: ease-in-out;
-moz-animation-fill-mode: both;
-o-animation-name: productslide;
-o-animation-duration: 1.1s;
-o-animation-delay: .5s;
-o-animation-timing-function: ease-in-out;
-o-animation-fill-mode: both;
}
#keyframes productslide {
0% {
margin-left: -50.5%;
}
100% {
margin-left: 30%;
}
}
#keyframes productslidemobile {
0% {
margin-left: -271%;
}
100% {
margin-left: 6%;
}
}
.productcardtext {
display: none;
position: relative;
height: 60%;
width: 40%;
top: 50.6%;
transform: translateY(-50%);
}
.productcard {
display: inline-block;
position: relative;
height: 60%;
width: 40%;
top: 50.6%;
transform: translateY(-50%);
}
.productcardlast {
display: inline-block;
position: relative;
height: 60%;
width: 40%;
top: 50.6%;
transform: translateY(-50%);
margin-right: 30%;
}
.productcardlastmobile {
display: none;
position: relative;
height: 60%;
width: 40%;
top: 50.6%;
transform: translateY(-50%);
}
.productcard img,
.productcardonly img,
.productcardfirst img,
.productcardlast img {
height: 100%;
width: auto;
}
#media screen and (orientation: portrait) {
#scrolling-wrapper::-webkit-scrollbar {
display: none;
}
.pricecontainermobile {
display: block;
position: absolute;
width: 100%;
margin: 0 auto;
}
.pricecontainermobile>h1 {
display: block;
font-family: neue-haas-grotesk-text, sans-serif;
color: white;
font-weight: 500;
font-style: normal;
list-style: none;
text-align: center;
text-decoration: none;
font-size: 13px;
top: 0;
}
#mobilewrapperpleaseworkimsosickofcodingihavenoideawhatimdoinglol {
z-index: 0;
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
width: 100%;
height: auto;
margin-top: -97px;
}
#scrolling-wrapper {
height: auto;
}
.productcard {
top: 0;
transform: none;
width: 88%;
padding-right: 3%;
height: auto;
}
.productcardlastmobile {
display: inline-block;
top: 0;
transform: none;
width: 88%;
padding-right: 3%;
height: auto;
}
.productcardtext {
display: inline-block;
top: 0;
transform: none;
width: 88%;
margin-right: 6%;
height: auto;
position: relative;
}
.productcardfirst {
top: 0;
transform: none;
margin-left: 6%;
padding-right: 3%;
width: 88%;
height: auto;
animation-name: productslidemobile;
animation-duration: 1.1s;
animation-delay: .5s;
animation-timing-function: ease-in-out;
animation-fill-mode: both;
-webkit-animation-name: productslidemobile;
-webkit-animation-duration: 1.1s;
-webkit-animation-delay: .5s;
-webkit-animation-timing-function: ease-in-out;
-webkit-animation-fill-mode: both;
-moz-animation-name: productslidemobile;
-moz-animation-duration: 1.1s;
-moz-animation-delay: .5s;
-moz-animation-timing-function: ease-in-out;
-moz-animation-fill-mode: both;
-o-animation-name: productslidemobile;
-o-animation-duration: 1.1s;
-o-animation-delay: .5s;
-o-animation-timing-function: ease-in-out;
-o-animation-fill-mode: both;
}
.productcardlast {
display: none;
}
.productcard img,
.productcardonly img,
.productcardfirst img,
.productcardtext img,
.productcardlastmobile img {
width: 100%;
height: auto;
}
}
first: love the #mobilewrapperpleaseworkimsosickofcodingihavenoideawhatimdoinglol ID, think i have some of those myself...
I think the problem is in the absolute/relative placement of the title. It's now inside of the scrollingwrapper. where it has no point being, it is not supposed to scroll.
So place .pricecontainermobile div outside the #scrollingwrapper, inside the #mobilewrapperpleaseworkimsosickofcodingihavenoideawhatimdoinglol and make that last one position:relative; (If possible in your layout).
I suspect the animation is pushing the title either outside the viewable space, or it triggers a placement bug in ios.
<div id="mobilewrapperpleaseworkimsosickofcodingihavenoideawhatimdoinglol">
<div id="scrolling-wrapper">
<div class="productcardfirst">
<img src="images/.jpg" alt="." class="productimage1">
</div>
<div class="productcard">
<img src="images/.jpg" alt="." class="productimage1">
</div>
<div class="productcardlast">
<img src="images/.jpg" alt="." class="productimage1">
</div>
<div class="productcardlastmobile">
<img src="images/.jpg" alt="." class="productimage1">
</div>
<div class="productcardtext">
<img src="images/.jpg" alt="." class="productimage1">
</div>
</div>
<div class="pricecontainermobile">
<h1>TITLE</h1>
</div>
I made the code work without the portrait exception,i advice you do the same, fix it on desktop and then test again on ios...
body {
background: black;
}
.pricecontainermobile {
}
*{border:1px #fc0 dotted;}
#horizontalproductcontainer {
z-index: 0;
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
width: 100%;
height: 100%;
display: flex;
align-items: center;
}
#mobilewrapperpleaseworkimsosickofcodingihavenoideawhatimdoinglol {
z-index: 0;
position: relative;
left: 0;
right: 0;
top: 0;
bottom: 0;
width: 100%;
height: 100%;
display: flex;
align-items: center;
}
#scrolling-wrapper {
overflow-x: auto;
overflow-y: hidden;
white-space: nowrap;
text-align: center;
margin: 0 auto;
height: 100%;
width: 100%;
-webkit-overflow-scrolling: touch;
-ms-overflow-style: none;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.productcardfirst {
display: inline-block;
position: relative;
height: 60%;
width: 40%;
top: 0%;
transform: translateY(-50%);
animation-name: productslide;
animation-duration: 1.1s;
animation-delay: .5s;
animation-timing-function: ease-in-out;
animation-fill-mode: both;
-webkit-animation-name: productslide;
-webkit-animation-duration: 1.1s;
-webkit-animation-delay: .5s;
-webkit-animation-timing-function: ease-in-out;
-webkit-animation-fill-mode: both;
-moz-animation-name: productslide;
-moz-animation-duration: 1.1s;
-moz-animation-delay: .5s;
-moz-animation-timing-function: ease-in-out;
-moz-animation-fill-mode: both;
-o-animation-name: productslide;
-o-animation-duration: 1.1s;
-o-animation-delay: .5s;
-o-animation-timing-function: ease-in-out;
-o-animation-fill-mode: both;
}
#keyframes productslide {
0% {
margin-left: -50.5%;
}
100% {
margin-left: 30%;
}
}
#keyframes productslidemobile {
0% {
margin-left: -271%;
}
100% {
margin-left: 6%;
}
}
.productcardtext {
display: none;
position: relative;
height: 60%;
width: 40%;
top: 50.6%;
transform: translateY(-50%);
}
.productcard {
display: inline-block;
position: relative;
height: 60%;
width: 40%;
top: 50.6%;
transform: translateY(-50%);
}
.productcardlast {
display: inline-block;
position: relative;
height: 60%;
width: 40%;
top: 50.6%;
transform: translateY(-50%);
margin-right: 30%;
}
.productcardlastmobile {
display: none;
position: relative;
height: 60%;
width: 40%;
top: 50.6%;
transform: translateY(-50%);
}
.productcard img,
.productcardonly img,
.productcardfirst img,
.productcardlast img {
height: 100%;
width: auto;
}
#media screen {
#scrolling-wrapper::-webkit-scrollbar {
display: none;
}
.pricecontainermobile {
display: block;
position: absolute;
width: 100%;
border:20px;
z-index:10;
bottom:0px;
transform:translateY(calc(100% - 5px)); /* push title underneath the bottom line */
margin: 0 auto;
}
.itemcontainer{
position:relative;
}
.pricecontainermobile>h1 {
display: block;
font-family: neue-haas-grotesk-text, sans-serif;
color: white;
font-weight: 500;
font-style: normal;
list-style: none;
text-align: center;
text-decoration: none;
font-size: 13px;
top: 0;
}
#mobilewrapperpleaseworkimsosickofcodingihavenoideawhatimdoinglol {
z-index: 0;
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
width: 100%;
height: auto;
}
.productimage1{
width:88%!important; /* added the 88% you mentioned */
}
#scrolling-wrapper {
height: auto;
max-height:90vh;
}
.productcard {
top: 0;
transform: none;
width: 88%;
padding-right: 3%;
height: auto;
}
.productcardlastmobile {
display: inline-block;
top: 0;
transform: none;
width: 88%;
padding-right: 3%;
height: auto;
}
.productcardtext {
display: inline-block;
top: 0;
transform: none;
width: 88%;
margin-right: 6%;
height: auto;
position: relative;
}
.productcardfirst {
top: 0;
transform: none;
margin-left: 6%;
padding-right: 3%;
width: 88%;
height: auto;
animation-name: productslidemobile;
animation-duration: 1.1s;
animation-delay: .5s;
animation-timing-function: ease-in-out;
animation-fill-mode: both;
-webkit-animation-name: productslidemobile;
-webkit-animation-duration: 1.1s;
-webkit-animation-delay: .5s;
-webkit-animation-timing-function: ease-in-out;
-webkit-animation-fill-mode: both;
-moz-animation-name: productslidemobile;
-moz-animation-duration: 1.1s;
-moz-animation-delay: .5s;
-moz-animation-timing-function: ease-in-out;
-moz-animation-fill-mode: both;
-o-animation-name: productslidemobile;
-o-animation-duration: 1.1s;
-o-animation-delay: .5s;
-o-animation-timing-function: ease-in-out;
-o-animation-fill-mode: both;
}
.productcardlast {
display: none;
}
.productcard img,
.productcardonly img,
.productcardfirst img,
.productcardtext img,
.productcardlastmobile img {
max-width: 100%;
max-height:100%;
}
}
<body>
<div id="horizontalproductcontainer">
<div id="mobilewrapperpleaseworkimsosickofcodingihavenoideawhatimdoinglol">
<div class="itemcontainer"><!-- extra container div just to hold your title -->
<div id="scrolling-wrapper">
<div class="productcardfirst">
<img src="https://via.placeholder.com/150" alt="." class="productimage1" />
</div>
<div class="productcard">
<img src="https://via.placeholder.com/150" alt="." class="productimage1" />
</div>
<div class="productcardlast">
<img src="https://via.placeholder.com/150" alt="." class="productimage1" />
</div>
<div class="productcardlastmobile">
<img src="https://via.placeholder.com/150" alt="." class="productimage1" />
</div>
<div class="productcardtext">
<img src="https://via.placeholder.com/150" alt="." class="productimage1" />
</div>
</div> <!-- end of scrolcontainer -->
<!-- text container-->
<div class="pricecontainermobile">
<h1>TITLE</h1>
</div>
<!-- /text container -->
</div>
<!-- ^ end of extra container that's just sitting here containing the scrollconatiner -->
</div>
</div>
</body>
Please try this css:
-Set #media all and set max-width.
#media all and (max-width: 900px) and (orientation: portrait)
.pricecontainermobile>h1 {
display: block;
font-family: neue-haas-grotesk-text, sans-serif;
color: white;
font-weight: 500;
font-style: normal;
list-style: none;
text-align: center;
text-decoration: none;
font-size: 13px;
top: 0;
}
I'm trying to move an img in a 3d space by using transform: translateZ().
here is a picture of what i have currently.
im trying to move the img icons around the box.
Here is what ive tried:
Using transform: translateZ(100px) in the id selectors for each img.
Using .box img:nthchild(7) {translateZ(100px)}.
Tried adding perspective to the .box class.
#animated-box {
position: absolute;
left: 67%;
top: 35%;
height: 300px;
width: 300px;
perspective: 1000px;
perspective-origin: 50% 50%;
cursor: pointer;
}
.box {
transform-style: preserve-3d;
width: 250px;
height: 250px;
position: relative;
animation: rotate 60s infinite;
z-index: 100;
}
.box div {
position: absolute;
width: 250px;
height: 250px;
opacity: 1;
background-color: #272727b2;
border: 1px solid #55FFEB;
box-shadow: inset 0 0 20px 5px rgb(85, 255, 235);
transition: all 1s ease;
z-index: 99;
}
#html-png {
top: 40%;
left: 60%;
height: 80px;
width: auto;
animation: crazy 45s infinite;
transform: translateY(1000px);
}
#js-png {
position: absolute;
top: 55%;
left: 35%;
height: 70px;
width: auto;
animation: crazy 45s infinite;
}
#css-png {
left: 10%;
top: 15%;
position: absolute;
height: 80px;
width: auto;
animation: crazy 45s infinite;
}
#boot-png {
left: 10%;
top: -17%;
position: absolute;
height: 80px;
width: auto;
animation: crazy 45s infinite;
}
#git-png {
left: 10%;
top: -17%;
position: absolute;
height: 80px;
width: auto;
animation: crazy 45s infinite;
}
#box-text {
position: relative;
top: 25%;
left: -20%;
width: 500px;
background-color: none;
color: white;
font-size: 20px;
opacity: 0;
transition: all 1s ease;
letter-spacing: .5px;
}
<!-- animated floating box -->
<section id="animated-box">
<div class="box">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<img id="html-png" src="imgs/html5.png" alt="">
<img id="css-png" src="imgs/css.png" alt="">
<img id="js-png" src="imgs/javascript.png" alt="">
<img id="boot-png" src="imgs/boot.png" alt="">
<img id="git-png" src="imgs/git.png" alt="">
</div>
<div id="box-text">Click cube to see the code running this page</div>
</section>
[![enter image description here][1]][1]
any advice would be welcome, thanks in advance.
I was wondering if it was possible to use jquery window.resize() to ensure the two donuts positioning never collides with the home text in the middle. I'm not sure how to link the x and y of the window size to change the top/left and bottom/right positioning values.
Or is there a way I could decrease the width and height of the donuts on window resize?
Any help would be appreciated!
html, body {
margin: 0;
}
#container {
width: 100vw;
height: 100vh;
background-color: pink;
display: flex;
align-items: center;
overflow: hidden;
position: relative;
}
#donut img,
#donut2 img {
width: 500px;
height: 500px;
}
#donut {
width: auto;
height: auto;
position: absolute;
animation: donut 2s;
animation-fill-mode: forwards;
}
#keyframes donut {
0% {
left: -20%;
top: -20%;
transform: translateZ(-100px);
}
100% {
left: -5%;
top: -5%;
transform: translateZ(100px);
}
}
#donut2 {
width: auto;
height: auto;
position: absolute;
animation: donut2 2s;
animation-fill-mode: forwards;
}
#keyframes donut2 {
0% {
right: -20%;
bottom: -20%;
transform: translateZ(-100px);
}
100% {
right: -5%;
bottom: -5%;
transform: translateZ(-100px);
}
}
#homeText {
width: 100%;
height: auto;
text-align: center;
font-size: 30px;
}
<div id="container">
<div id="donut">
<img src="https://upload.wikimedia.org/wikipedia/commons/a/a5/Glazed-Donut.jpg">
</div>
<div id="homeText">
<p>
Reward Points
</p>
<p>Get Your Daily Sweet Rewards</p>
</div>
<div id="donut2">
<img src="https://upload.wikimedia.org/wikipedia/commons/a/a5/Glazed-Donut.jpg">
</div>
</div>
Please Try This. I think this should be work:-
#container {
width: 100vw;
height: 100vh;
background-color: pink;
display: flex;
align-items: center;
-webkit-justify-content: center;
justify-content: center;
}
#donut { width:30vw; }
#donut2 { width:30vw; }
#donut2 img, #donut img {
width: 100%;
max-width:100%;
height:auto;
}
#donut {
position: absolute;
animation: donut 2s;
animation-fill-mode: forwards;
}
#keyframes donut {
0% {
left: -5%;
top: -5%;
transform: translateZ(-100px);
}
100% {
left: 5%;
top: 5%;
transform: translateZ(100px);
}
}
#donut2 {
position: absolute;
animation: donut2 2s;
animation-fill-mode: forwards;
}
#keyframes donut2 {
0% {
right: -5%;
bottom: -5%;
transform: translateZ(-100px);
}
100% {
right: 5%;
bottom: 5%;
transform: translateZ(-100px);
}
}
#homeText {
width: 25vw;
height: auto;
text-align: center;
font-size: 30px;
}
I have the following code.
#mf-loader-container {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
width: 500px;
height: 30px;
}
.mf-loader-circle {
position: absolute;
height: 30px;
width: 30px;
border-radius: 50%;
border: 2px solid #03C9A9;
top: -15px;
background: white;
text-align: center;
line-height: 30px;
color: #03C9A9;
}
.mf-loader-text {
position: absolute;
width: 150px;
top: 20px;
}
#one-text {
left: -10px;
}
#two-text {
left: 200px;
}
#three-text {
left: 480px;
}
#two {
left: 240px;
}
#three {
left: 490px;
}
#mf-loader {
width: 100%;
height: 3px;
background: #03C9A9;
position: absolute;
-webkit-animation: mymove 5s;
/* Chrome, Safari, Opera */
animation: mymove 5s;
border-radius: 3px;
}
/* Chrome, Safari, Opera */
#-webkit-keyframes mymove {
0% {
width: 0px;
}
50% {
width: 50%;
}
100% {
width: 100%;
}
}
/* Standard syntax */
#keyframes mymove {
0% {
width: 0px;
}
50% {
width: 50%;
}
100% {
width: 100%;
}
}
<div id="mf-loader-container">
<div id="mf-loader">
<div class="mf-loader-circle" id="one">
1
</div>
<div class="mf-loader-circle" id="two">
2
</div>
<div class="mf-loader-circle" id="three">
3
</div>
<div class="mf-loader-text" id="one-text">
Each day will be better than last.
<br>This one especially
</div>
<div class="mf-loader-text" id="two-text">
Subscribing .. Thank you for subscribing. We appreciate it!
</div>
<div class="mf-loader-text" id="three-text">
DONE
</div>
</div>
</div>
It is a simple loader using CSS keyframes. Now I'm trying to control the opacity of the text elements beneath the numbers inside the keyframe animations. I'm trying to change the opacity of each text from 0 to 1 as the line reaches that particular point (keyframe reaches respective % ) - Is this possible in CSS alone ?
You can create that by defining another keyframes just for changing font-color and by even including animation-delay, animation-fill-mode to change font-color when line reaches at the end point.
animation-delay :
The animation-delay CSS property specifies when the animation should
start. This lets the animation sequence begin some time after it's
applied to an element.
animation-fill-mode :
The animation-fill-mode CSS property specifies how a CSS animation
should apply styles to its target before and after it is executing.
#mf-loader-container {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
width: 500px;
height: 30px;
}
.mf-loader-circle {
position: absolute;
height: 30px;
width: 30px;
border-radius: 50%;
border: 2px solid #03C9A9;
top: -15px;
background: white;
text-align: center;
line-height: 30px;
color: #03C9A9;
}
.mf-loader-text {
position: absolute;
width: 150px;
top: 20px;
}
#one-text {
left: -10px;
-webkit-animation: cl 3s;
}
#two-text {
left: 200px;
-webkit-animation: cl 3s;
-webkit-animation-delay:2s;
-webkit-animation-fill-mode:forwards;
color:rgba(1,1,1,0.6);
}
#three-text {
left: 480px;
-webkit-animation: cl 3s;
-webkit-animation-delay:3s;
-webkit-animation-fill-mode:forwards;
color:rgba(1,1,1,0.6);
}
#-webkit-keyframes cl{
from{
color:rgba(1,1,1,0.6);
}
to{
color:rgba(1,1,1,1);
}
}
#two {
left: 240px;
}
#three {
left: 490px;
}
#mf-loader {
width: 100%;
height: 3px;
background: #03C9A9;
position: absolute;
-webkit-animation: mymove 5s;
/* Chrome, Safari, Opera */
animation: mymove 5s;
border-radius: 3px;
}
/* Chrome, Safari, Opera */
#-webkit-keyframes mymove {
0% {
width: 0px;
}
50% {
width: 50%;
}
100% {
width: 100%;
}
}
/* Standard syntax */
#keyframes mymove {
0% {
width: 0px;
}
50% {
width: 50%;
}
100% {
width: 100%;
}
}
<div id="mf-loader-container">
<div id="mf-loader">
<div class="mf-loader-circle" id="one">
1
</div>
<div class="mf-loader-circle" id="two">
2
</div>
<div class="mf-loader-circle" id="three">
3
</div>
<div class="mf-loader-text" id="one-text">
Each day will be better than last.
<br>This one especially
</div>
<div class="mf-loader-text" id="two-text">
Subscribing .. Thank you for subscribing. We appreciate it!
</div>
<div class="mf-loader-text" id="three-text">
DONE
</div>
</div>
</div>