Text moves to the right during typing text animation CSS - html

After each typing text animation, the next text is slightly moved to the right. How do I make sure that the text keeps aligned left? "text-align: left" and "margin-left:0" do not work. When I include "margin-right: 100%" it keeps aligned left, but each text comes on a new line, which is not what I want.
.text_1 {
animation: text1;
max-width: 12.5em;
padding-bottom: 0.1em;
}
.text_2 {
animation: text2;
max-width: 9.1em;
padding-bottom: 0.1em;
}
.text_3 {
animation: text3;
max-width: 5.3;
padding-bottom: 0.1em;
}
.text_4 {
animation: text4;
max-width: 15;
padding-bottom: 0.1em;
}
.text_5 {
animation: text5;
max-width: 15.2;
padding-bottom: 0.1em;
}
.text_1,
.text_2,
.text_3,
.text_4,
.text_5 {
overflow: hidden;
white-space: nowrap;
display: inline-block;
position: relative;
animation-duration: 20s;
animation-timing-function: steps(25, end);
animation-iteration-count: infinite;
}
.text_1::after,
.text_2::after,
.text_3::after,
.text_4::after,
.text_5::after {
content: "|";
position: absolute;
right: 0;
animation: caret infinite;
animation-duration: 1s;
animation-timing-function: steps(1, end);
}
#keyframes text5 {
0%,
80%,
100% {
width: 0;
}
85%,
95% {
width: 15.2em;
}
}
#keyframes text4 {
0%,
60%,
80%,
100% {
width: 0;
}
65%,
75% {
width: 15em;
}
}
#keyframes text3 {
0%,
40%,
60%,
100% {
width: 0;
}
45%,
55% {
width: 5.3em;
}
}
#keyframes text2 {
0%,
20%,
40%,
100% {
width: 0;
}
25%,
35% {
width: 9.1em;
}
}
#keyframes text1 {
0%,
20%,
100% {
width: 0;
}
5%,
15% {
width: 12.5em;
}
}
#keyframes caret {
0%,
100% {
opacity: 0;
}
50% {
opacity: 1;
}
}
h1 {
font-family: Segoe UI Black;
}
h2 {
font-family: Segoe UI Black;
}
h3 {
font-family: Segoe UI Black;
}
h4 {
font-family: Segoe UI Black;
}
h5 {
font-family: Segoe UI Black;
}
h6 {
font-family: Segoe UI Black;
}
.container-text {
padding-top: 5em;
padding-left: 5em;
padding-bottom: 30em;
margin-top: 3;
}
.container-fluid {
margin-top: 5em;
}
#title {
font-size: 3em;
}
#subtitle {
font-size: 2.5em;
font-family: Segoe UI Light;
margin-bottom: 1em;
background: red;
}
#subsubtitle {
font-size: 1.5em;
font-family: Segoe UI Light;
color: #BFBFBF;
margin-bottom: 1em;
}
<div class="container-fluid">
<div class="row">
<div class="col-lg-8 container-text">
<h1 id="title">Title</h1>
<h2 id="subtitle">
<span class="text_1">Tailor your marketing strategy</span>
<span class="text_2">Gauge public opinion</span>
<span class="text_3">Study trends</span>
<span class="text_4">Explore variables like demographics</span>
<span class="text_5">Monitor sentiment related to a topic</span>
</h2>
</div>
</div>
</div>

You could apply a flex-box style to the parent container ( the h2#subtitle ) and align the contents to the start of the flex-box
.text_1 {
animation: text1;
max-width: 12.5em;
padding-bottom: 0.1em;
}
.text_2 {
animation: text2;
max-width: 9.1em;
padding-bottom: 0.1em;
}
.text_3 {
animation: text3;
max-width: 5.3;
padding-bottom: 0.1em;
}
.text_4 {
animation: text4;
max-width: 15;
padding-bottom: 0.1em;
}
.text_5 {
animation: text5;
max-width: 15.2;
padding-bottom: 0.1em;
}
.text_1,
.text_2,
.text_3,
.text_4,
.text_5 {
overflow: hidden;
white-space: nowrap;
display: inline-block;
position: relative;
animation-duration: 20s;
animation-timing-function: steps(25, end);
animation-iteration-count: infinite;
}
.text_1::after,
.text_2::after,
.text_3::after,
.text_4::after,
.text_5::after {
content: "|";
position: absolute;
right: 0;
animation: caret infinite;
animation-duration: 1s;
animation-timing-function: steps(1, end);
}
/* flexbox on parent */
h2#subtitle{
display:flex;
flex-direction:row;
align-items:flex-start;
}
#keyframes text5 {
0%,
80%,
100% {
width: 0;
}
85%,
95% {
width: 15.2em;
}
}
#keyframes text4 {
0%,
60%,
80%,
100% {
width: 0;
}
65%,
75% {
width: 15em;
}
}
#keyframes text3 {
0%,
40%,
60%,
100% {
width: 0;
}
45%,
55% {
width: 5.3em;
}
}
#keyframes text2 {
0%,
20%,
40%,
100% {
width: 0;
}
25%,
35% {
width: 9.1em;
}
}
#keyframes text1 {
0%,
20%,
100% {
width: 0;
}
5%,
15% {
width: 12.5em;
}
}
#keyframes caret {
0%,
100% {
opacity: 0;
}
50% {
opacity: 1;
}
}
h1 {
font-family: Segoe UI Black;
}
h2 {
font-family: Segoe UI Black;
}
h3 {
font-family: Segoe UI Black;
}
h4 {
font-family: Segoe UI Black;
}
h5 {
font-family: Segoe UI Black;
}
h6 {
font-family: Segoe UI Black;
}
.container-text {
padding-top: 5em;
padding-left: 5em;
padding-bottom: 30em;
margin-top: 3;
}
.container-fluid {
margin-top: 5em;
}
#title {
font-size: 3em;
}
#subtitle {
font-size: 2.5em;
font-family: Segoe UI Light;
margin-bottom: 1em;
background: red;
}
#subsubtitle {
font-size: 1.5em;
font-family: Segoe UI Light;
color: #BFBFBF;
margin-bottom: 1em;
}
<div class="container-fluid">
<div class="row">
<div class="col-lg-8 container-text">
<h1 id="title">Title</h1>
<h2 id="subtitle">
<span class="text_1">Tailor your marketing strategy</span>
<span class="text_2">Gauge public opinion</span>
<span class="text_3">Study trends</span>
<span class="text_4">Explore variables like demographics</span>
<span class="text_5">Monitor sentiment related to a topic</span>
</h2>
</div>
</div>
</div>

Related

How can I center an animation so it goes from the middle?

An example of what I want (the main text eg. subscribe): https://sounddrout.com/
My code basically has a repeating typewriter effect on it and it just goes from right to left. Although I want it to do so but in a centered fashion (Check the website linked as an example). I want it to come out from the middle so its equal on both sides and expands out. Think like the center thing in google docs.
body {
margin: 0px;
}
.container {
display: grid;
grid-template-columns: 1fr;
}
/*Text*/
.font {
font-family: 'Source Sans Pro', monospace;
}
.mid {
text-align: center;
}
.txtsize {
font-size: 40px;
}
h1 {
width: max-content;
position: relative;
font-size: 40px;
display: grid;
}
.textbody {
margin: 120px;
font-family: "Source Sans Pro", sans-serif;
display: grid;
place-content: center;
text-align: center;
background: var(--bg-color);
font: 200;
}
/*typwriter*/
:root {
--bg-color: hsl;
--typewriterSpeed: 5s;
--blinkLength: 650ms;
--typewriterCharacters: 20;
}
/* Type Writer Effect */
h1::before,
h1::after {
content: "";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
h1::before {
background: white;
animation: typewriter var(--typewriterSpeed) steps(20) infinite;
}
h1::after {
width: 0.1em;
background: black;
animation: typewriter var(--typewriterSpeed) steps(20) infinite;
}
#keyframes typewriter {
from {
left: 0%;
}
45% {
left: 100%;
}
65% {
left: 100%;
}
85% {
left: 0%;
}
to {
left: 0%;
}
}
#keyframes blink {
0% {
opacity: 1;
}
50% {
opacity: 0;
}
100% {
opacity: 1;
}
}
<body>
<div class="textbody">
<h1>
Subscribe To FuryRex09
</h1>
</div>
</body>
Any ideas?
Sorry if I wasn't very clear I had a lot of trouble explaining my issue.
P.S here's a Codepen - https://codepen.io/furyrex09/pen/bGaybOe (;
if you can use JavaScript . this we be lot easier to do .
$("#typed").typed({
strings: ["This is first.", "This is second.", "Add any text you like here."],
typeSpeed: 100,
startDelay: 0,
backSpeed: 60,
backDelay: 2000,
loop: true,
cursorChar: "|",
contentType: 'html'
});
#import url('https://fonts.googleapis.com/css?family=Work+Sans');
html, body {
height: 100vh;
font-family: 'Work Sans', sans-serif;
font-weight: bold;
color: #fff;
letter-spacing: 5px;
}
body {
display: flex;
justify-content: center;
align-items: center;
background-size: cover;
background: linear-gradient(to right, #0cebeb, #20e3b2, #29ffc6);
margin: 0;
}
.type-wrap {
font-size: 50px;
padding: 20px;
}
/* the above is for styling puposes only */
.typed-cursor{
opacity: 1;
-webkit-animation: blink 0.7s infinite;
-moz-animation: blink 0.7s infinite;
animation: blink 0.7s infinite;
}
#keyframes blink{
0% { opacity:1; }
50% { opacity:0; }
100% { opacity:1; }
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/typed.js/1.1.1/typed.min.js"></script>
<div class="type-wrap">
<span id="typed" style="white-space:pre;" class="typed">
</span>
</div>
Here's my solution to this:
// TYPEWRITER //
const typedTextSpan = document.querySelector(".typed-text");
const cursorSpan = document.querySelector(".cursor");
const textArray = ["YouTuber", "Writer", "Designer", "Creator", "Programmer", "Gamer"]
const typingDelay = 200;
const erasingDelay = 100;
const newTextDelay = 2000;
let textArrayIndex = 0;
let charIndex = 0;
function type() {
if(charIndex < textArray[textArrayIndex].length) {
if(!cursorSpan.classList.contains("typing")) cursorSpan.classList.add("typing");
typedTextSpan.textContent += textArray[textArrayIndex].charAt(charIndex);
charIndex++;
setTimeout(type, typingDelay);
}
else {
cursorSpan.classList.remove("typing");
setTimeout(erase, newTextDelay);
}
}
function erase() {
if(charIndex > 0) {
if(!cursorSpan.classList.contains("typing")) cursorSpan.classList.add("typing");
typedTextSpan.textContent = textArray[textArrayIndex].substring(0,charIndex-1);
charIndex--;
setTimeout(erase, erasingDelay)
}
else {
cursorSpan.classList.remove("typing");
textArrayIndex++;
if(textArrayIndex>=textArray.length) textArrayIndex=0;
setTimeout(type, typingDelay + 800);
}
}
document.addEventListener("DOMContentLoaded", function() {
if(textArray.length) setTimeout(type, newTextDelay + 250);
});
/* Text */
h1 {
position: relative;
font-size: 40px;
}
.textbody {
margin-top: 100px;
font-family: "Source Sans Pro", sans-serif;
font-weight: bold;
background: var(--bg-color);
font: 200;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
}
.typed-text {
font-weight: normal;
color: #dd7732;
}
/* Root */
:root {
--bg-color: hsl;
--typewriterSpeed: 5s;
--blinkLength: 825ms;
--typewriterCharacters: 20;
}
/* Type Writer Effect */
.cursor {
display: inline-block;
width: 3px;
background-color: #ccc;
margin-left: 0.1rem;
animation: blink 1s infinite;
}
.cursor.typing {
animation: none;
}
#keyframes blink {
0% {background-color: #ccc;}
49% {background-color: #ccc; }
50% {background-color: transparent; }
99% {background-color: transparent; }
100% {background-color: #ccc; }
}
<body>
<div class="textbody">
<h1>
I am a <span class="typed-text"></span><span class="cursor typing"> </span>
</h1>
</div>
<script src="main.js"></script>
</body>

Unexpected dip on keyframe start

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

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>

Text not displayed after applying some css

There is h1 tag in the body which has Some Text Hello Some Text.
But while executing the word Hello is missed. Why?.
On view-source: it shows that there is a word written.
How to solve that?
.container {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
/*background-color: red*/
}
.clr {
color: #f35626;
background-image: -webkit-linear-gradient(92deg,#f35626,#feab3a);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
-webkit-animation: hue 30s infinite linear;
}
#-webkit-keyframes hue {
from {
-webkit-filter: hue-rotate(0deg);
}
to {
-webkit-filter: hue-rotate(360deg);
}
}
.awesome {
font-family: futura;
font-style: italic;
color:#313131;
font-size:45px;
font-weight: bold;
position: absolute;
-webkit-animation:colorchange 20s infinite alternate;
}
#-webkit-keyframes colorchange {
0% {
color: blue;
}
10% {
color: #8e44ad;
}
20% {
color: #1abc9c;
}
30% {
color: #d35400;
}
40% {
color: blue;
}
50% {
color: #34495e;
}
60% {
color: blue;
}
70% {
color: #2980b9;
}
80% {
color: #f1c40f;
}
90% {
color: #2980b9;
}
100% {
color: pink;
}
}
<!DOCTYPE html>
<html><head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body class=""><div class="container"><br /><br /><center><b><h2 class="clr">नमस्ते</h2><br /><h1 class="clr">Some Text <span class="awesome">HELLO</span> Some Text</h1></b></center></div></body></html>
There is h1 tag in the body which has Some Text Hello Some Text.
But while executing the word Hello is missed. Why?.
On view-source: it shows that there is a word written.
How to solve that?
The Tidy Js fiddle
First you have to correct your markup as you have obsolete tags and don't use absolute position. Then simply put back the text-fill to initial.
.container {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
/*background-color: red*/
}
.clr {
text-align:center;
font-weight:bold;
color: #f35626;
background-image:linear-gradient(92deg, #f35626, #feab3a);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
animation: hue 30s infinite linear;
}
#keyframes hue {
from {
-webkit-filter: hue-rotate(0deg);
}
to {
-webkit-filter: hue-rotate(360deg);
}
}
.awesome {
font-family: futura;
font-style: italic;
color: #313131;
font-size: 45px;
font-weight: bold;
-webkit-background-clip: initial;
-webkit-text-fill-color: initial;
animation: colorchange 20s infinite alternate;
}
#keyframes colorchange {
0% {
color: blue;
}
10% {
color: #8e44ad;
}
20% {
color: #1abc9c;
}
30% {
color: #d35400;
}
40% {
color: blue;
}
50% {
color: #34495e;
}
60% {
color: blue;
}
70% {
color: #2980b9;
}
80% {
color: #f1c40f;
}
90% {
color: #2980b9;
}
100% {
color: pink;
}
}
<div class="container">
<h2 class="clr">नमस्ते</h2>
<h1 class="clr">Some Text <span class="awesome">HELLO</span> Some Text</h1>
</div>
Simply remove position absolute of .awesome
.container {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
/*background-color: red*/
}
.clr {
color: #f35626;
background-image: -webkit-linear-gradient(92deg,#f35626,#feab3a);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
-webkit-animation: hue 30s infinite linear;
}
#-webkit-keyframes hue {
from {
-webkit-filter: hue-rotate(0deg);
}
to {
-webkit-filter: hue-rotate(360deg);
}
}
.awesome {
font-family: futura;
font-style: italic;
color:#313131;
font-size:45px;
font-weight: bold;
-webkit-animation:colorchange 20s infinite alternate;
}
#-webkit-keyframes colorchange {
0% {
color: blue;
}
10% {
color: #8e44ad;
}
20% {
color: #1abc9c;
}
30% {
color: #d35400;
}
40% {
color: blue;
}
50% {
color: #34495e;
}
60% {
color: blue;
}
70% {
color: #2980b9;
}
80% {
color: #f1c40f;
}
90% {
color: #2980b9;
}
100% {
color: pink;
}
}
<!DOCTYPE html>
<html><head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body class=""><div class="container"><br /><br /><center><b><h2 class="clr">नमस्ते</h2><br /><h1 class="clr">Some Text <span class="awesome">HELLO</span> Some Text</h1></b></center></div></body></html>
You have position:absolute; on your .awesome. If this is removed, you will see the text.
.awesome {
font-family: futura;
font-style: italic;
color:#313131;
font-size:45px;
font-weight: bold;
-webkit-animation:colorchange 20s infinite alternate;
}
Replace this In this I removed Position:absolute;

Animated text within box

I have the following jsfiddle.
With the following code:
HTML:
<div class="animated-box">Animated box</div>
CSS:
.animated-box {
border:2px solid #bada55;
border-radius: 10px 0;
color: #bada55;
font-size: 20px;
font-weight:bold;
text-align:center;
padding:50px;
width:200px;
-webkit-animation:fontbulger 1s infinite;
-moz-animation: fontbulger 5s infinite;
-o-animation: fontbulger 1s infinite;
animation: fontbulger 1s infinite;
}
#-webkit-keyframes fontbulger {
0%, 100% {
font-size: 15px;
}
50% {
font-size: 20px;
}
}
#-moz-keyframes fontbulger {
0%, 100% {
font-size: 15px;
}
50% {
font-size: 20px;
}
}
#-o-keyframes fontbulger {
0%, 100% {
font-size: 15px;
}
50% {
font-size: 20px;
}
}
#keyframes fontbulger {
0%, 100% {
font-size: 15px;
}
50% {
font-size: 20px;
}
}
How can I change the size of the text, but not the size of the box?
Specify a line-height, for example
line-height:20px;
http://jsfiddle.net/uexwLy75/2/
Give it a height: 30px;
.animated-box {
border:2px solid #bada55;
border-radius: 10px 0;
color: #bada55;
font-size: 20px;
font-weight:bold;
text-align:center;
padding:50px;
width:200px;
height: 30px;
-webkit-animation:fontbulger 1s infinite;
-moz-animation: fontbulger 5s infinite;
-o-animation: fontbulger 1s infinite;
animation: fontbulger 1s infinite;
}
#-webkit-keyframes fontbulger {
0%, 100% {
font-size: 15px;
}
50% {
font-size: 20px;
}
}
#-moz-keyframes fontbulger {
0%, 100% {
font-size: 15px;
}
50% {
font-size: 20px;
}
}
#-o-keyframes fontbulger {
0%, 100% {
font-size: 15px;
}
50% {
font-size: 20px;
}
}
#keyframes fontbulger {
0%, 100% {
font-size: 15px;
}
50% {
font-size: 20px;
}
}
<div class="animated-box">Animated box</div>