Can someone please review the following block of code and tell me why the animation on the image div and info div are not working.
this is the html file for the about page. (i had enclosed the block content in a div and given it position relative)
{%extends 'layout.html' %}
{%block content %}
.about {
align-items: center;
top: 5em;
display: flex;
flex-direction: row;
justify-content: center;
box-sizing: border-box;
width: 100%;
max-width: 100%;
}
#image {
animation-name: image2;
animation-duration: 3s;
animation-delay: 3s;
animation-fill-mode: forwards;
}
.image-file {
border: none;
border-radius: 100px;
width: 200px;
height: 200px;
margin-right: 100px;
}
#info {
text-align: center;
max-width: 100%;
-webkit-animation-name: info2;
-webkit-animation-duration: 3s;
-webkit-animation-fill-mode: forwards;
animation-name: info2;
animation-duration: 3s;
animation-fill-mode: forwards;
}
#keyframes image2 {
0% {
left: -100px;
}
100% {
left: 0;
}
}
#-webkit-keyframes info2 {
0% {
right: -100px;
}
100% {
right: 0;
}
}
#keyframes info2 {
0% {
right: -100px;
}
100% {
right: 0;
}
}
<div class='head1'>
<h class='head'>Welcome to the Home page</h>
</div>
<div class='about'>
<div id='image'>
<image class='image-file' src='https://via.placeholder.com/150' alt='nelson'>
</div>
<div id='info'>
<h class='head'>About me</h>
<p class='text'>I am a web developer specialized in vanilla css,<br> html and flask. <br>But i am developing further.</p>
</div>
</div>
Try adding:
#image { position:absolute; }
If you are using Firefox, open the dev tools, locate the div image, and see the styles info.
You will see something like this
Notice that left is grayed. Now, hover on the "i" circle. You will see a message stating "left has no effect because the element is not positioned".
So, this is your problem
.about {
align-items: center;
top: 5em;
display: flex;
flex-direction: row;
justify-content: center;
box-sizing: border-box;
width: 100%;
max-width: 100%;
}
#image {
animation-name: image2;
animation-duration: 3s;
animation-delay: 3s;
animation-fill-mode: forwards;
position: relative; /* added */
}
.image-file {
border: none;
border-radius: 100px;
width: 200px;
height: 200px;
margin-right: 100px;
}
#info {
text-align: center;
max-width: 100%;
-webkit-animation-name: info2;
-webkit-animation-duration: 3s;
-webkit-animation-fill-mode: forwards;
animation-name: info2;
animation-duration: 3s;
animation-fill-mode: forwards;
position: relative; /* added */
}
#keyframes image2 {
0% {
left: -100px;
}
100% {
left: 0;
}
}
#-webkit-keyframes info2 {
0% {
right: -100px;
}
100% {
right: 0;
}
}
#keyframes info2 {
0% {
right: -100px;
}
100% {
right: 0;
}
}
<div class='head1'>
<h class='head'>Welcome to the Home page</h>
</div>
<div class='about'>
<div id='image'>
<image class='image-file' src='https://via.placeholder.com/150' alt='nelson'>
</div>
<div id='info'>
<h class='head'>About me</h>
<p class='text'>I am a web developer specialized in vanilla css,<br> html and flask. <br>But i am developing further.</p>
</div>
</div>
Related
the keyframes i created in my scss should be animating my height to make it a 2s animation but it has not done that instead the height is just transforming instantly but the width in the same keyframe is being animated.
#import url("https://fonts.googleapis.com/css2?family=Maven+Pro:wght#500&family=Roboto&display=swap");
* {
font-family: "Maven Pro", sans-serif;
color: white;
animation-delay: 1s;
}
body {
width: 100%;
height: 100vh;
margin: 0%;
background-color: green;
display: flex;
justify-content: center;
align-items: flex-end;
overflow: hidden;
position: absolute;
bottom: 5%;
}
.swipe {
animation-name: swipeWidthHeight, close;
animation-duration: 0.3s 2s;
animation-delay: 1s, 10s;
animation-fill-mode: forwards, forwards;
display: flex;
justify-content: center;
height: 179px;
width: 434px;
background-color: #fff;
}
.swipe .side {
width: 180px;
height: 100%;
background-color: #fff;
display: flex;
justify-content: center;
animation-name: imageSize;
animation-fill-mode: forwards;
animation-duration: 0.3s;
}
.swipe .side img {
width: 80%;
}
.swipe .center {
position: relative;
animation-name: centerExpand;
animation-fill-mode: forwards;
animation-duration: 0.3s;
width: 74px;
height: 100%;
background-color: #38003c;
display: flex;
justify-content: center;
align-items: center;
}
.swipe .center .popup.firstHalf {
opacity: 0;
position: absolute;
transform: translateX(-50%);
left: 50%;
width: 135px;
height: 35px;
background-color: white;
color: #38003c;
text-align: center;
font-family: "roboto";
font-size: 22px;
line-height: 35px;
font-weight: 500;
animation-name: firstHalf;
animation-delay: 2s;
animation-duration: 3s;
animation-fill-mode: forwards;
}
.swipe .center .popup.eaSports {
opacity: 0;
position: absolute;
transform: translateX(-50%);
left: 50%;
width: 110px;
height: 76px;
background-color: #38003c;
color: #38003c;
display: flex;
align-items: center;
justify-content: center;
animation-name: firstHalf;
animation-delay: 4.8s;
animation-duration: 3s;
animation-fill-mode: forwards;
}
.swipe .center .popup.eaSports img {
width: 61px;
}
.swipe .center .textContainer {
font-weight: 400;
opacity: 0;
margin: 0% 2% 0% 2%;
height: 100%;
width: 100%;
}
.swipe .center .textContainer.left {
text-align: right;
animation-delay: 1.15s;
animation-name: leftText;
animation-duration: 0.2s;
animation-fill-mode: forwards;
animation-timing-function: cubic-bezier(0.34, 0.58, 0.37, 1.48);
}
.swipe .center .textContainer.right {
animation-name: rightText;
animation-delay: 1.15s;
animation-duration: 0.2s;
animation-fill-mode: forwards;
animation-timing-function: cubic-bezier(0.34, 0.58, 0.37, 1.48);
}
.swipe .center img {
width: 44px;
}
#keyframes swipeWidthHeight {
0% {
height: 179px;
width: 434px;
}
100% {
height: 77px;
width: 1064px;
}
}
#keyframes centerExpand {
90% {
justify-content: space-between;
}
100% {
width: 1020px;
justify-content: space-between;
}
}
#keyframes rightText {
0% {
opacity: 1;
}
100% {
padding-left: 10%;
opacity: 1;
}
}
#keyframes leftText {
0% {
opacity: 1;
}
100% {
padding-right: 10%;
opacity: 1;
}
}
#keyframes imageSize {
100% {
height: 77px;
width: 77px;
}
}
#keyframes firstHalf {
0% {
opacity: 1;
bottom: 0%;
z-index: -1;
}
10% {
z-index: -1;
opacity: 1;
bottom: 100%;
}
90% {
z-index: -1;
opacity: 1;
bottom: 100%;
}
99% {
z-index: -1;
opacity: 1;
bottom: 0%;
}
100% {
z-index: -1;
opacity: 0;
bottom: 0%;
}
}
#keyframes close {
100% {
width: 1064px;
height: 77px;
bottom: -20%;
}
}
<body>
<div class="swipe">
<div class="left side">
<img src="https://cdn.discordapp.com/attachments/868038988437536768/918357217772732446/crest.svg" alt="">
</div>
<div class="center">
<div class="firstHalf popup">First Half</div>
<div class="eaSports popup">
<img src="https://cdn.discordapp.com/attachments/868038988437536768/918357218003415080/ea-sports-logo.png" alt="">
</div>
<div class="textContainer left">
<h1 class="text ">MANCHESTER CITY</h1>
</div>
<img src="https://cdn.discordapp.com/attachments/868038988437536768/918357218208907274/premier-league-icon.png" alt="">
<div class="textContainer right">
<h1 class="text ">MANCHESTER CITY</h1>
</div>
</div>
<div class="right side">
<img src="https://cdn.discordapp.com/attachments/868038988437536768/918357217772732446/crest.svg" alt="">
</div>
</div>
</body>
In the codepen the class "swipe" and key frame of 'swipeWidthHeight'is the element thats is having issues with the height not animating.
here is a codepen below if the whole project for a better understanding
https://codepen.io/charlieschuyler/pen/zYBZzZv
Comma Missing:
.swipe {
animation-name: swipeWidthHeight, close;
animation-duration: 0.3s, 2s; /* missing comma */
animation-delay: 1s, 10s;
animation-fill-mode: forwards, forwards;
display: flex;
justify-content: center;
height: 179px;
width: 434px;
background-color: #fff;
}
I am creating a loading logo for splash screen.animation looks exactly like this.so when I tried this code but my logo isn't positioned center as I wanted and also the logo is going down as the device length is increasingit is looking like this.supposed to be like this.i am using ionic4/angular8.
ion-content{
--background:yellow;
}
.tree {
left: 0;
right: 10%;
margin:0 auto;
top:50%;
transform:translateY(-50%);
position: relative;
}
.tree > div {
position: absolute;
height: 100%;
width: 100%;
background: yellow;
top: 0;
left: 0;
-webkit-animation-name: hello;
-webkit-animation-duration: 5s;
-webkit-animation-fill-mode: forwards;
animation-name: hello;
animation-duration: 5s;
animation-fill-mode: forwards;
}
.tree img {
max-width: 100%;
}
#keyframes hello {
0% {
height: 100%;
}
100% {
height: 0%;
}
}
#-webkit-keyframes hello {
0% {
height: 100%;
}
100% {
height: 0%;
}
}
<ion-content>
<div class="tree">
<div></div>
<img src="logo.svg" />
</div>
<ion-content>
You can use margin: 0 auto
.tree {
margin: 0 auto;
}
You also can use flexbox to solve this (https://css-tricks.com/snippets/css/a-guide-to-flexbox/)
Playing around with the height which is currently using 80vh (view height) you could determine the position vertically. which is different when using another type of device (screen height)
.tree {
display: flex;
justify-content: center;
align-items: center;
height: 80vh;
}
.tree > div {
position: absolute;
height: 100%;
width: 100%;
background: #fff;
top: 0;
left: 0;
-webkit-animation-name: hello;
-webkit-animation-duration: 5s;
-webkit-animation-fill-mode: forwards;
animation-name: hello;
animation-duration: 5s;
animation-fill-mode: forwards;
}
.tree img {
max-width: 300px;
}
#keyframes hello {
0% {
height: 100%;
}
100% {
height: 0%;
}
}
#-webkit-keyframes hello {
0% {
height: 100%;
}
100% {
height: 0%;
}
}
<div class="tree">
<div></div>
<img src="http://www.colourbox.com/preview/4221089-363386-green-vector-tree-nature-symbol.jpg" alt="" />
</div>
Simple center the div
<ion-content>
<center>
<div class="tree">
<div></div>
<img src="logo.svg" />
</div>
</center>
<ion-content>
ion-content{
--background:yellow;
}
.tree {
position: absolute;
left:50%;
top:50%;
margin-top:-50px;
margin-left:-50px;
}
.tree img {
max-width: 100px;
}
#keyframes hello {
0% {
height: 100%;
}
100% {
height: 0%;
}
}
#-webkit-keyframes hello {
0% {
height: 100%;
}
100% {
height: 0%;
}
}
<ion-content>
<div class="tree">
<div class="loader-img">
<img src="http://www.colourbox.com/preview/4221089-363386-green-vector-tree-nature-symbol.jpg" />
</div>
</div>
<ion-content>
I have created this progress bar and I just can't make it stop at the end. Currently its stopping at 70% and gets cleared. Any ideas? Is there any kind of animation setting to stop it at 100%?
.wrap {
background-color: #f2f2f2;
height: 10px;
width: 400px;
margin: 0 auto;
position: relative;
top: 20px;
margin-bottom: 20px;
}
.bar {
background: #ffcc00;
height: 10px;
width: 0%;
}
.animating {
-webkit-animation: progress 3s ;
}
#-webkit-keyframes progress {
0% {
width: 0%;
}
100% {
width: 70%;
}
}
<div class="wrap">
<div class="bar animating"></div>
</div>
animation-fill-mode: forwards; or -webkit-animation: progress 3s forwards;
Try to use 100% in:
#-webkit-keyframes progress {
0% {
width: 0%;
}
100% {
width: 70%; /* edit to 100% */
}
}
A Fancy version
.wrap {
background-color: #f2f2f2;
height: 10px;
width: 400px;
margin: 0 auto;
position: relative;
top: 20px;
margin-bottom: 20px;
}
.wrap div {
background-color: #ffcc00;
height: 10px;
width: 0%;
border-radius: 5px;
animation: loadbar 3s;
-webkit-animation: loadbar 3s;
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards;
}
#-webkit-keyframes loadbar {
0% {
width: 0%;
}
100% {
width: 100%;
}
#keyframes loadbar {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
<div class="wrap">
<div class="bar animating"></div>
</div>
I am trying to stagger the opacity (fade) of three boxes via an infinite keyframe animation and the animation-delay property.
I am getting some unexpected behavior, as the third box fades away, it suddenly reappears faintly ("flickers") before the animation starts again. I am experiencing this across browsers.
I would like to use pseudo elements if possible, is there a known fix for this keyframe bug?
HTML
<div class="container">
<div class="child">
<div></div>
</div>
</div>
SCSS
.container {
position: fixed;
left: 150px;
top: 50px;
.child {
position: absolute;
animation:mymove 1s infinite;
&::before{
display: block;
position: absolute;
width: 25px;
height: 25px;
background-color: red;
content: "";
right: 40px;
animation: inherit;
animation-delay: .15s;
}
div {
width: 25px;
height: 25px;
background-color: red;
animation: inherit;
animation-delay: .30s;
}
&::after{
display: block;
position: absolute;
width: 25px;
height: 25px;
background-color: red;
content: "";
left: 40px;
bottom: 0px;
animation: inherit;
animation-delay: .45s;
}
}
}
#keyframes mymove {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
JS Fiddle
The reason they flicker is because you have set an animation on their parent, the child.
And since its animation doesn't have a delay, it starts before its children, but will then be overridden by them as soon as their delay has passed, hence one can see a quick flash.
The best way to avoid any future issue with this, is to remove the animation from the child
.container {
position: fixed;
left: 150px;
top: 50px;
}
.container .child {
position: absolute;
}
.container .child::before {
display: block;
position: absolute;
width: 25px;
height: 25px;
background-color: red;
content: "";
right: 40px;
animation: mymove 1s infinite;
animation-delay: 0.15s;
}
.container .child div {
width: 25px;
height: 25px;
background-color: red;
animation: mymove 1s infinite;
animation-delay: 0.3s;
}
.container .child::after {
display: block;
position: absolute;
width: 25px;
height: 25px;
background-color: red;
content: "";
left: 40px;
bottom: 0px;
animation: mymove 1s infinite;
animation-delay: 0.45s;
}
#keyframes mymove {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
<div class="container">
<div class="child">
<div></div>
</div>
</div>
I have the following code to have text slide in, but after the slide is over the text moves to the left. How would I make the text stay where it is when the slide is over?
<style>
div.slide-left {
width: 100%;
overflow: hidden;
}
div.slide-left p {
animation: slide-left 5s;
font-size: 300%;
color: #000;
position: absolute;
top: 50px;
}
#keyframes slide-left {
from {
margin-left: 100%;
width: 300%;
}
to {
margin-left: 50%;
width: 100%;
}
}
</style>
<div class="slide-left">
<p>hello</p>
</div>
You need to use animation-fill-mode: forwards to preserve the last animation state. Since there was no animation-fill-mode specified, it used the default properties of the class name, i.e. resets/jumps to the top value specified after the animation is completed.
<style>
div.slide-left {
width: 100%;
overflow: hidden;
}
div.slide-left p {
animation: slide-left 5s;
font-size: 300%;
color: #000;
position: absolute;
top: 50px;
animation-fill-mode: forwards;
}
#keyframes slide-left {
from {
margin-left: 100%;
width: 300%;
}
to {
margin-left: 50%;
width: 100%;
}
}
</style>
<div class="slide-left">
<p>hello</p>
</div>