Unexpected dip on keyframe start - html

I have a snippet which displays a text every 7 seconds. However at the beginning of each animation it performs an unexpected dip which i can't rule out. Can you find what it is?
Here's the pen.
.chillquote {
font-size: 1.5em;
line-height: 1.5em;
text-align: center;
padding: 1em;
color: var(--bodyColor);
height: 4em;
font-family: var(--usedH-font-stack);
}
div {
display: inline-block;
overflow: hidden;
}
div:first-of-type {
/* For increasing performance
ID/Class should've been used.
For a small demo
it's okaish for now */
animation: showup 7s infinite;
}
div:last-of-type {
width: 0px;
animation: reveal 7s infinite;
}
div:last-of-type span {
margin-left: -50rem;
animation: slidein 7s infinite;
}
#keyframes showup {
0% {
opacity: 0;
}
20% {
opacity: 1;
}
80% {
opacity: 1;
}
100% {
opacity: 0;
}
}
#keyframes slidein {
0% {
margin-left: -800px;
}
20% {
margin-left: -800px;
}
35% {
margin-left: 0px;
}
100% {
margin-left: 0px;
}
}
#keyframes reveal {
0% {
opacity: 0;
width: 0px;
}
20% {
opacity: 1;
width: 0px;
}
30% {
width: auto;
}
80% {
opacity: 1;
}
100% {
opacity: 0;
width: auto;
}
}
<div class="chillquote">
<div>
Q
</div>
<div>
<span >
{{ randomQ.quote }}
<i><span style=" font-size: 0.5em;">~ {{ randomQ.author }}</span></i>
</span>
</div>
</div>

It's because you are using inline-block to display the all the divs.
When the text that appears starts out, you have a width of 0 set in the reveal animation - when it starts to appear you go from 0 to auto.
Since the quote text starts out as multi-line, the baseline changes so the Q "drops" down to the text baseline.
I've updated your pen to make the .chillquote display block and added classes to the other divs - because last-child and first-child were also effecting the .chillquote div because you never specified a child element.
I also set the final width to a percentage.
.chillquote {
font-size: 1.5em;
line-height: 1.5em;
text-align: left;
padding: 1em;
color: var(--bodyColor);
height: 4em;
font-family: var(--usedH-font-stack);
}
.chillquote div {
display: inline-block;
overflow: hidden;
}
div.first {
/* For increasing performance
ID/Class should've been used.
For a small demo
it's okaish for now */
animation: showup 7s infinite;
}
div.second {
width: 0px;
animation: reveal 7s infinite;
}
div.second span {
margin-left: -50rem;
animation: slidein 7s infinite;
}
#keyframes showup {
0% {
opacity: 0;
}
20% {
opacity: 1;
}
80% {
opacity: 1;
}
100% {
opacity: 0;
}
}
#keyframes slidein {
0% {
margin-left: -800px;
}
20% {
margin-left: -800px;
}
35% {
margin-left: 0px;
}
100% {
margin-left: 0px;
}
}
#keyframes reveal {
0% {
opacity: 0;
width: 0px;
}
20% {
opacity: 1;
width: 0px;
}
30% {
width: 80%;
}
80% {
opacity: 1;
}
100% {
opacity: 0;
width: 80%;
}
}
<div class="chillquote">
<div class="first">
Q
</div>
<div class="second">
<span>Here is the quote<i> <span style="font-size: 0.5em;">~ Author</span></i>
</span>
</div>
</div>
https://codepen.io/chrislafrombois/pen/zYYpVQz
EDIT
For centered text, we can use display: flex and animate the flex-basis property to max-content.
.chillquote {
font-size: 1.5em;
line-height: 1.5em;
padding: 1em;
color: var(--bodyColor);
height: 4em;
font-family: var(--usedH-font-stack);
display: flex;
justify-content: center;
}
div.first {
animation: showup 7s infinite;
text-align: right;
}
div.second {
width: 0px;
animation: reveal 7s infinite;
text-align: left;
overflow: hidden;
}
div.second span.quote {
animation: slidein 7s infinite;
}
#keyframes showup {
0% {
opacity: 0;
}
20% {
opacity: 1;
}
80% {
opacity: 1;
}
100% {
opacity: 0;
}
}
#keyframes slidein {
0% {
margin-left: -100vw;
}
20% {
margin-left: -100vw;
}
35% {
margin-left: 0;
}
100% {
margin-left: 0;
}
}
#keyframes reveal {
0% {
opacity: 0;
flex-basis: 0;
}
20% {
opacity: 1;
flex-basis: 0;
}
30% {
flex-basis: max-content;
}
80% {
opacity: 1;
}
100% {
opacity: 0;
flex-basis: max-content;
}
}
<div class="chillquote">
<div class="first">
Q
</div>
<div class="second">
<span class="quote">Eleifend nec eget. Id massa quis eu vitae elit. Bibendum interdum semper. Donec libero duis.<i> <span style="font-size: 0.5em;">~ {{ randomQ.author }}</span></i>
</span>
</div>
</div>
New CodePen: https://codepen.io/chrislafrombois/pen/zYYRzOY

Related

how do i make a button fade in with css keyframes?

I'm trying to make my button fade in with keyframes but it isn't working and I know I'm doing something wrong. I ended up getting the animated text to work but this is giving me a headache and I cannot find info anywhere that has helped me... I'm new to web development so don't be too harsh on me or my (probably ugly and unorganized) code lol. I'm trying to learn as much as I can, so if you can please explain why it isn't working and why something else might? Thanks guys <3
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="style.css">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght#300&display=swap" rel="stylesheet">
<title>Welcome! | Video Editing by Scottis</title>
</head>
<body>
<!-- Header -->
<div class="container">
<span class="text1">Video Editing by Scottis</span>
</div>
<!-- Buttons -->
<style>
.btn {
background-color: white;
color: rgb(133, 4, 255);
text-align: center;
font-size: 15px;
font-weight: bold;
margin-right: -250px;
margin-top: 600px;
margin-left: 515px;
padding: 30px;
}
</style>
</head>
<body>
<button class="btn">Portfolio</button>
<button class = "btn">Pricing</button>
<button class="btn">Contact</button>
</body>
</html>
My CSS:
* {
box-sizing: border-box;
padding: 0;
margin: 0;
font-family: sans-serif;
}
body {
margin: 0;
font-family: 'Roboto', sans-serif;
}
body {
background-image: url("./assets/background.png");
background-color: #cccccc;
background-repeat: no-repeat;
}
/* Create three equal columns that floats next to each other */
.col-md-3 {
float: left;
width: 15%;
padding: 15px;
padding: 10px;
margin: auto;
display: block;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Responsive layout - makes the three columns stack on top of each other instead of next to each other */
#media screen and (max-width:768px) {
.col-md-3 {
width: 100% auto;
}
}
.col-md-12 {
text-align: center;
}
.card-title {
text-align: center;
}
.container{
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100%;
}
.container span{
color: white;
text-transform: uppercase;
display: block;
}
.text1{
color: white;
font-size: 60px;
font-weight: 700;
letter-spacing: 8px;
margin-bottom: 20px;
position: relative;
animation: text 3s 1;
}
#keyframes text {
0%{
margin-bottom: -20%;
}
30%{
letter-spacing: 25px;
margin-bottom: -40px;
}
85%{
letter-spacing: 15px;
margin-bottom: -40px;
}
}
}
#keyframes button {
0%{
opacity: 0%;
}
0%{
opacity: 0%;
}
25%{
opacity: 25%;
}
50%{
opacity: 50%;
}
75%{
opacity: 75%;
}
100%{
opacity: 100%;
}
}
You have some issues with your code first off. You are repeating both the head and body tags out of proper valid html sequence. Have a close look at the following page and resource from MDN: https://developer.mozilla.org/en-US/docs/Web/HTML/Element
As to your issue with keyframes, define the class you wish to control with the sequence in your css and add the animation with a unique call name, I used fadeIn. Below I have added Mozilla, webkit, opera and ms #keyframe animations for opacity. I am defining the animation to start the timer (3 seconds) #keyframe 0% { opacity: 0; } , then end at 100% { opacity: 1; }. I add multiple kits for different browsers.
.btn {
animation: fadeIn ease 3s;
-webkit-animation: fadeIn ease 3s;
-moz-animation: fadeIn ease 3s;
-o-animation: fadeIn ease 3s;
-ms-animation: fadeIn ease 3s;
}
#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;
}
}
* {
box-sizing: border-box;
padding: 0;
margin: 0;
font-family: sans-serif;
}
body {
margin: 0;
font-family: 'Roboto', sans-serif;
}
body {
background-image: url("./assets/background.png");
background-color: #cccccc;
background-repeat: no-repeat;
}
/* Start class for buttons animation fadeIn ease */
.btn {
animation: fadeIn ease 3s;
-webkit-animation: fadeIn ease 3s;
-moz-animation: fadeIn ease 3s;
-o-animation: fadeIn ease 3s;
-ms-animation: fadeIn ease 3s;
}
#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;
}
}
/* End of animation keyframes */
/* Create three equal columns that floats next to each other */
.col-md-3 {
float: left;
width: 15%;
padding: 15px;
padding: 10px;
margin: auto;
display: block;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Responsive layout - makes the three columns stack on top of each other instead of next to each other */
#media screen and (max-width:768px) {
.col-md-3 {
width: 100% auto;
}
}
.col-md-12 {
text-align: center;
}
.card-title {
text-align: center;
}
.container {
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100%;
}
.container span {
color: white;
text-transform: uppercase;
display: block;
}
.text1 {
color: white;
font-size: 60px;
font-weight: 700;
letter-spacing: 8px;
margin-bottom: 20px;
position: relative;
animation: text 3s 1;
}
#keyframes text {
0% {
margin-bottom: -20%;
}
30% {
letter-spacing: 25px;
margin-bottom: -40px;
}
85% {
letter-spacing: 15px;
margin-bottom: -40px;
}
}
}
<div class="container">
<span class="text1">Video Editing by Scottis</span>
</div>
<button class="btn">Portfolio</button>
<button class="btn">Pricing</button>
<button class="btn">Contact</button>

I am trying to add the 6th animation but I don't know why it's doesn't show

I copied this code from codepen and there is only 5 text looping I want to add the 6th to show but when i copy the same style with new class name i.e "w6" and the new animation with "w6anim" it doesn't load the 6th waqas. Kindly help!
I tried to change #keyframe values but still, it doesn't work.
#font-face {
font-family: system;
font-style: normal;
font-weight: 600;
src: local(".SFNSText-Light"), local(".HelveticaNeueDeskInterface-Light"), local(".LucidaGrandeUI"), local("Ubuntu Light"), local("Segoe UI Light"), local("Roboto-Light"), local("DroidSans"), local("Tahoma");
}
* {
margin: 0;
padding: 0;
background: transparent;
font-family: "system";
}
.container {
width: 200px;
}
.word {
font-size: 3em;
font-weight: bold;
float: left;
opacity: 0;
position: absolute;
top: 40%;
left: 40%;
}
.w1 {
animation: w1anim 20s infinite;
}
.w2 {
animation: w2anim 20s infinite;
}
.w3 {
animation: w3anim 20s infinite;
}
.w4 {
animation: w4anim 20s infinite;
}
.w5 {
animation: w5anim 20s infinite;
}
.w6 {
animation: w6anim 20s infinite;
color: red;
}
#keyframes w1anim {
0% {
opacity: 0;
}
5% {
opacity: 1;
}
10% {
opacity: 0;
}
}
#keyframes w2anim {
10% {
opacity: 0;
}
15% {
opacity: 1;
}
20% {
opacity: 0;
}
}
#keyframes w3anim {
20% {
opacity: 0;
}
25% {
opacity: 1;
}
30% {
opacity: 0;
}
}
#keyframes w4anim {
30% {
opacity: 0;
}
35% {
opacity: 1;
}
40% {
opacity: 0;
}
}
#keyframes w5anim {
40% {
opacity: 0;
}
45% {
opacity: 1;
}
50% {
opacity: 0;
}
}
#keyframes w6anim {
50% {
opacity: 0 !important;
}
55% {
opacity: 1 !important;
}
60% {
opacity: 0 !important;
}
}
<div class="container">
<div class="word w1">LOREM</div>
<div class="word w2">IPSUM</div>
<div class="word w3">CARPE</div>
<div class="word w4">DIEM</div>
<div class="word w5">AVENO</div>
<div class="word w6">waqas</div>
</div>
link to the codepen https://codepen.io/waqasahmad9961/pen/bGbxpNr
Remote !important and simply copy 1:1 in future cases.. never change a running system
#keyframes w6anim {
50% {
opacity: 0 !important;
}
55% {
opacity: 1 !important;
}
60% {
opacity: 0 !important;
}
}
Remove -> !important

Animation Flip HTML5 and CSS3 Doubts

I need do the next animation of text:
People dissapears like a flip effect David Walsh Flip Card Effect, and the effect faces every 2 seconds and it will be repeating, contents the text: "Robots", "Animals", "Things" for example, with the flip animation.
Any idea?
One example of flip cards is the next: Stackoverflow How to flip multiple divs using CSS?
#import url('https://fonts.googleapis.com/css?family=Roboto:300');
.divi {
line-height: normal;
color: black;
text-shadow: 0 0 0.2em #87F, 0 0 0.2em #87F, 0 0 0.2em #87F;
}
.div1 { /* For increasing performance ID/Class should've been used. For a small demo it's okaish for now */
animation: showup 7s forwards;
font-family:'Roboto';
font-weight:300;
font-size:28px;
overflow:hidden;
display:inline-block;
white-space:nowrap;
}
.div2 {
font-family: 'Roboto';
font-weight: 300;
font-size: 28px;
overflow: hidden;
width: 0px;
animation: reveal 7s forwards;
animation-iteration-count: 1;
display: inline-block;
white-space: nowrap;
}
.div2 span {
font-family: 'Roboto';
font-weight: 300;
font-size: 28px;
overflow: hidden;
margin-left: -355px;
animation: slidein 7s forwards;
}
#keyframes showup {
0% {
opacity: 0;
}
20% {
opacity: 1;
}
80% {
opacity: 1;
}
100% {
opacity: 1;
}
}
#keyframes slidein {
0% {
margin-left: -800px;
}
20% {
margin-left: -800px;
}
35% {
margin-left: 0px;
}
100% {
margin-left: 0px;
}
}
#keyframes reveal {
0% {
opacity: 0;
width: 0px;
}
20% {
opacity: 1;
width: 0px;
}
30% {
width: auto;
}
80% {
opacity: 1;
}
100% {
opacity: 1;
width: auto;
}
}
<div class="divi" align="center">
<div class="div1">Hello</div>
<div class="div2">
<span>People</span>
</div>
<div class="div3">
<span>Robots</span>
</div>
<div class="div4">
<span>Animals</span>
</div>
<div class="div5">
<span>Things</span>
</div>
</div>

Hyperlink only partially clickable

So I have just started to learn HTML/CSS and I am trying to create a website for a magazine I'm putting together. However, when I try adding two links to two different pieces of text, one is only partially clickable and the one below is not.
I am thinking it has something to do with my wrapper or the photos I have right beside the text because when I align them more right, they're now clickable. Seems to be like something is blocking part of the word (link) to be clicked on.
I have tried making a sidebar instead but I still get the same result. I tried moving my code around for different results, but still cannot figure it out.
#wrapper {
margin: 0 auto;
width: 1140px;
}
.slider {
max-width: 457px;
height: 451px;
margin: 0 auto;
position: relative;
}
.slide1,
.slide2,
.slide3,
.slide4,
.slide5 {
position: absolute;
width: 100%;
height: 100%;
}
.slide1 {
background: url(TPWeb.jpg)no-repeat center;
background-size: cover;
animation: fade 80s infinite;
-webkit-animation: fade 20s infinite;
margin-top: 20px;
margin-left: -155px;
}
.slide2 {
background: url(DS.jpg)no-repeat center;
background-size: cover;
animation: fade2 80s infinite;
-webkit-animation: fade2 20s infinite;
margin-top: 20px;
margin-left: -155px;
}
.slide3 {
background: url(IT95Web.jpg)no-repeat center;
background-size: cover;
animation: fade3 80s infinite;
-webkit-animation: fade3 20s infinite;
margin-top: 20px;
margin-left: -155px;
}
#font-face {
font-family:
}
#keyframes fade1 {
0% {
opacity: 1
}
33.333% {
opacity: 0
}
66.666% {
opacity: 0
}
100% {
opacity: 1
}
}
#keyframes fade2 {
0% {
opacity: 0
}
33.333% {
opacity: 1
}
66.666% {
opacity: 0
}
100% {
opacity: 0
}
}
#keyframes fade3 {
0% {
opacity: 0
}
33.333% {
opacity: 0
}
66.666% {
opacity: 1
}
100% {
opacity: 0
}
}
}
.TPWeb {
margin-top: 80px;
margin-left: 50px;
}
.DFBase1 {
margin-top: 45px;
margin-left: 183px;
width: 448px;
height: 127px;
}
.ATA {
margin-right: 305px;
margin-top: -475px;
font-family:
}
.B {
margin-right: 370px;
font-family:
}
.about {
color: #000;
text-decoration: none;
}
.blog {
color: #000;
text-decoration: none;
}
<div id="wrapper">
<div class='slider'>
<div class='slide1'></div>
<div class='slide2'></div>
<div class='slide3'></div>
</div>
<img src="DFBase1.png" alt="DFBase" class=DFBase1>
<div align="right" class=ATA>
<font size="5"><em><b>about the author</b></em></font>
</div>
<div align="right" class=B>
<font size="5"><em><b>blog</b></em></font>
</div>
</div>
.slider is overlapping the links since you're using a negative margin to move the links back up on the page.
A simple fix is to give the links a z-index by assigning position: relative
.ATA, .B {
position: relative;
}
#wrapper {
margin: 0 auto;
width: 1140px;
}
.slider {
max-width: 457px;
height: 451px;
margin: 0 auto;
position: relative;
}
.slide1,
.slide2,
.slide3,
.slide4,
.slide5 {
position: absolute;
width: 100%;
height: 100%;
}
.slide1 {
background: url(TPWeb.jpg)no-repeat center;
background-size: cover;
animation: fade 80s infinite;
-webkit-animation: fade 20s infinite;
margin-top: 20px;
margin-left: -155px;
}
.slide2 {
background: url(DS.jpg)no-repeat center;
background-size: cover;
animation: fade2 80s infinite;
-webkit-animation: fade2 20s infinite;
margin-top: 20px;
margin-left: -155px;
}
.slide3 {
background: url(IT95Web.jpg)no-repeat center;
background-size: cover;
animation: fade3 80s infinite;
-webkit-animation: fade3 20s infinite;
margin-top: 20px;
margin-left: -155px;
}
#font-face {
font-family:
}
#keyframes fade1 {
0% {
opacity: 1
}
33.333% {
opacity: 0
}
66.666% {
opacity: 0
}
100% {
opacity: 1
}
}
#keyframes fade2 {
0% {
opacity: 0
}
33.333% {
opacity: 1
}
66.666% {
opacity: 0
}
100% {
opacity: 0
}
}
#keyframes fade3 {
0% {
opacity: 0
}
33.333% {
opacity: 0
}
66.666% {
opacity: 1
}
100% {
opacity: 0
}
}
}
.TPWeb {
margin-top: 80px;
margin-left: 50px;
}
.DFBase1 {
margin-top: 45px;
margin-left: 183px;
width: 448px;
height: 127px;
}
.ATA {
margin-right: 305px;
margin-top: -475px;
font-family:
}
.B {
margin-right: 370px;
font-family:
}
.about {
color: #000;
text-decoration: none;
}
.blog {
color: #000;
text-decoration: none;
}
<div id="wrapper">
<div class='slider'>
<div class='slide1'></div>
<div class='slide2'></div>
<div class='slide3'></div>
</div>
<img src="DFBase1.png" alt="DFBase" class=DFBase1>
<div align="right" class=ATA>
<font size="5"><em><b>about the author</b></em></font>
</div>
<div align="right" class=B>
<font size="5"><em><b>blog</b></em></font>
</div>
</div>

How to reduce specific text size in text animation?

I have created a text sliding animation that has a fixed text (SM) and two 'LI's that will slide and replace eachother (ART and allART). What I need is for "all" from SMallART to be in a smaller size.
body {
width: 50%;
height: 50%;
position: fixed;
background-color: #F2F2F2;
}
.content {
width: 537px;
font-size: 62px;
line-height: 80px;
font-family: 'Muli';
color: #FE642E;
height: 100px;
position: absolute;
top: 50%;
left: 50%;
margin-top: -40px;
margin-left: 130px;
}
.visible {
float: left;
font-weight: 800;
overflow: hidden;
height: 80px;
}
p {
display: inline;
float: left;
margin: 0;
}
ul {
margin-top: 0;
padding-left: 101px;
text-align: left;
list-style: none;
animation: 6s linear 0s normal none infinite change;
-webkit-animation: 6s linear 0s normal none infinite change;
-moz-animation: 6s linear 0s normal none infinite change;
-o-animation: 6s linear 0s normal none infinite change;
}
ul li {
line-height: 80px;
margin: 0;
}
#-webkit-keyframes opacity {
0% {
opacity: 0;
}
50% {
opacity: 1;
}
100% {
opacity: 0;
}
}
#keyframes opacity {
0% {
opacity: 0;
}
50% {
opacity: 1;
}
100% {
opacity: 0;
}
}
#-webkit-keyframes change {
0% {
margin-top: 0;
}
15% {
margin-top: 0;
}
25% {
margin-top: -40px;
}
35% {
margin-top: -60px;
}
45% {
margin-top: -80px;
}
55% {
margin-top: -80px;
}
65% {
margin-top: -80px;
}
75% {
margin-top: -60px;
}
85% {
margin-top: -40px;
}
100% {
margin-top: 0;
}
}
#keyframes change {
0% {
margin-top: 0;
}
15% {
margin-top: 0;
}
25% {
margin-top: -40px;
}
35% {
margin-top: -60px;
}
45% {
margin-top: -80px;
}
55% {
margin-top: -80px;
}
65% {
margin-top: -80px;
}
75% {
margin-top: -60px;
}
85% {
margin-top: -40px;
}
100% {
margin-top: 0;
}
}
<link href='http://fonts.googleapis.com/css?family=Muli' rel='stylesheet' type='text/css'>
<div class="content">
<div class="visible">
<p>
SM
</p>
<ul>
<li>ART</li>
<li>allART</li>
</ul>
</div>
</div>
So,how to reduce only the "all"text size.
Try defining a parent div ( for the general paragraph styling ), and a child div ( for a specific paragraph styling), and you can achieve your desired functionality, try this:
HTML
<div class="big-text">sm<div class="small-text">all</div>art</div>
CSS
.full-text {
display:inline;
font-size:22px;
}
.small-text {
display:inline;
font-size:10px;
}
The Jsfiddle:
Differnet Sizes