Like a progress bar:
span {
display: inline-block;
width: 20%;
text-align: center;
outline: 1px solid black;
font-weight: bold;
}
span:nth-child(1) {
animation: bar 1s linear;
}
#keyframes bar {
0% {
color: black;
background: white;
}
100% {
color: white;
background: black;
}
}
<p><span>1</span><span>2</span><span>3</span><span>4</span><span>5</span></p>
I'd like the next <span> to blink for a second and then the third one and so on. Is it possible with CSS?
Use the following CSS:
span {
display: inline-block;
width: 20%;
text-align: center;
outline: 1px solid black;
font-weight: bold;
color: black;
background: white;
}
span:nth-child(1){
animation: bar 1s linear 0s forwards;
}
span:nth-child(2){
animation: bar 1s linear 1s forwards;
}
span:nth-child(3){
animation: bar 1s linear 2s forwards;
}
span:nth-child(4){
animation: bar 1s linear 3s forwards;
}
span:nth-child(5){
animation: bar 1s linear 4s forwards;
}
#keyframes bar {
0% {
color: black;
background: white;
}
100% {
color: white;
background: black;
}
}
<p><span>1</span><span>2</span><span>3</span><span>4</span><span>5</span></p>
With CSS you can just declare static code, so if you know exactly how many spans will be used there is no problem. If you want something recursive (first then the next one, until there are spans) you can do that only with JS.
Note that in this example I know precisely how many child the p has.
span {
display: inline-block;
width: 20%;
text-align: center;
outline: 1px solid black;
font-weight: bold;
color: black;
background: white;
animation: bar 5s linear infinite;
}
span:nth-child(2) {
animation-delay: 1s;
}
span:nth-child(3) {
animation-delay: 2s;
}
span:nth-child(4) {
animation-delay: 3s;
}
span:nth-child(5) {
animation-delay: 4s;
}
#keyframes bar {
0% {
color: black;
background: white;
}
10% {
color: white;
background: black;
}
11% {
color: black;
background: white;
}
100% {
color: black;
background: white;
}
}
<p><span>1</span><span>2</span><span>3</span><span>4</span><span>5</span></p>
Related
I would like to make an animation that makes the text appear with a prompt like in the following video: https://uploads-ssl.webflow.com/61f84f92347c1507dede5924/624f203e8226d749d47b0806_Animation_Slogan_logo-final-transcode.mp4
But I don't understand how to make it responsive on phone and web, would you have any instructions please?
Also how can I make the border blink on the first 3 words too?
Here is the result I managed to get:
.typewriter {
max-width: 170px;
height: 250px;
position: absolute;
top: 78%;
right: 33%;
transform: translate(33%, -78%);
}
.typewriter p {
height: fit-content;
border-right: .15em solid rgb(0, 0, 0);
font-family: futura-pt;
white-space: nowrap;
overflow: hidden;
letter-spacing: 20px;
font-size: 100%;
}
.typewriter p:nth-child(1) {
width: 90%;
animation: type2 4s steps(40, end);
animation-fill-mode: forwards;
}
.typewriter p:nth-child(2) {
width: 90%;
opacity: 0;
animation: type2 4s steps(40, end);
animation-delay: 4s;
animation-fill-mode: forwards;
}
.typewriter p:nth-child(3) {
width: 90%;
opacity: 0;
animation: type2 4s steps(40, end);
animation-delay: 8s;
animation-fill-mode: forwards;
}
.typewriter p:nth-child(4) {
width: 90%;
opacity: 0;
animation: type2 5s steps(40, end), blink .5s step-end infinite alternate;
animation-delay: 12s;
animation-fill-mode: forwards;
}
#keyframes blink {
50% {
border-color: transparent;
}
}
#keyframes blink2 {
0% {
border-right: .15em solid rgb(0, 0, 0);
}
50% {
border-color: transparent;
}
100% {
border: none;
}
}
#keyframes type {
0% {
width: 0;
}
99.9% {
border-right: .15em solid rgb(0, 0, 0);
}
100% {
border: none;
}
}
#keyframes type2 {
0% {
width: 0;
}
1% {
opacity: 1;
}
99.9% {
border-right: .15em solid rgb(0, 0, 0);
}
100% {
opacity: 1;
border: none;
}
}
#keyframes type3 {
0% {
width: 0;
}
1% {
opacity: 1;
}
100% {
opacity: 1;
}
}
<header>
<h1 class="home-title"><img src="images/logo.png" alt="Invisible" /></h1>
<div class="typewriter" id="typewriter">
<p>keep</p>
<p>your</p>
<p>eyes</p>
<p>open</p>
</div>
</header>
I was trying to make a multiple texts changing color animation, like this https://vercel.com. I've nailed down how to make one text change color through keyframes but I can't get them to each text change color on a certain pattern.
For instance enter image description here, you have the word Develop in color red, then it should turn to black and change to the word Preview on blue, and then this would turn to black and the word Ship should turn yellow. And finally this should iterate infinitely.
Here I leave the current code in case it helps:
.center {
margin: 0 auto;
padding-top: 10rem;
}
.awesome {
width: 100%;
margin: 0 auto;
text-align: center;
color: #313131;
font-size: 45px;
font-weight: bold;
position: flex;
-webkit-animation: color-change-red 10s infinite alternate;
-moz-animation: color-change-red 10s infinite alternate;
-o-animation: color-change-red 10s infinite alternate;
-ms-animation: color-change-red 10s infinite alternate;
animation: color-change-red 10s infinite alternate;
}
#-webkit-keyframes color-change-red {
0% { color: red; }
33.3% { color: black; }
100% { color: black; }
}
#-moz-keyframes color-change-red {
0% { color: red; }
33.3% { color: black; }
100% { color: black; }
}
#-ms-keyframes color-change-red {
0% { color: red; }
33.3% { color: black; }
100% { color: black; }
}
#-o-keyframes color-change-red {
0% { color: red; }
33.3% { color: black; }
100% { color: black; }
}
#keyframes color-change-red {
0% { color: red; }
33.3% { color: black; }
100% { color: black; }
}
.awesome2 {
width: 100%;
margin: 0 auto;
text-align: center;
color: #313131;
font-size: 45px;
font-weight: bold;
position: flex;
-webkit-animation: color-change-blue 10s infinite alternate;
-moz-animation: color-change-blue 10s infinite alternate;
-o-animation: color-change-blue 10s infinite alternate;
-ms-animation: color-change-blue 10s infinite alternate;
animation: color-change-blue 10s infinite alternate;
}
#-webkit-keyframes color-change-blue {
0% { color: black; }
33.3% { color: blue; }
66.6% { color: black; }
}
#-moz-keyframes color-change-blue {
0% { color: black; }
33.3% { color: blue; }
66.6% { color: black; }
}
#-ms-keyframes color-change-blue {
0% { color: black; }
33.3% { color: blue; }
66.6% { color: black; }
}
#-o-keyframes color-change-blue {
0% { color: black; }
33.3% { color: blue; }
66.6% { color: black; }
}
#keyframes color-change-blue {
0% { color: black; }
33.3% { color: blue; }
66.6% { color: black; }
}
.awesome3 {
width: 100%;
margin: 0 auto;
text-align: center;
color: #313131;
font-size: 45px;
font-weight: bold;
position: flex;
-webkit-animation: color-change-yellow 10s infinite alternate;
-moz-animation: color-change-yellow 10s infinite alternate;
-o-animation: color-change-yellow 10s infinite alternate;
-ms-animation: color-change-yellow 10s infinite alternate;
animation: color-change-yellow 10s infinite alternate;
}
#-webkit-keyframes color-change-yellow {
0% { color: black; }
66.6% { color: yellow; }
100% { color: black; }
}
#-moz-keyframes color-change-yellow {
0% { color: black; }
66.6% { color: yellow; }
100% { color: black; }
}
#-ms-keyframes color-change-yellow {
0% { color: black; }
66.6% { color: yellow; }
100% { color: black; }
}
#-o-keyframes color-change-yellow {
0% { color: black; }
66.6% { color: yellow; }
100% { color: black; }
}
#keyframes color-change-yellow {
0% { color: black; }
66.6% { color: yellow; }
100% { color: black; }
}
<div class='center'>
<p class="awesome">Develop</p>
<p class="awesome2">Preview</p>
<p class="awesome3">Ship</p>
</div>
One observation is that in the example site you link to it appears that the colored words stay colored for a bit rather than immediately start to merge with black.
This snippet holds them colored for 30% of the animation, then quite swiftly takes them down to black at a third of the way through the animation.
The other observation is that there is a lot of repeated code here which can make it difficult to see what is going on.
This snippet gives each word the same animation but delays the second one by a third of the total animation time and the third one by two thirds.
It also uses a CSS variable for the color so the same keyframes code can be used for each word.
For clarity it also strips out the browser-specific settings - of course put them back in if required in your use case.
.center {
margin: 0 auto;
padding-top: 10rem;
}
.awesome {
width: 100%;
margin: 0 auto;
text-align: center;
color: #313131;
font-size: 45px;
font-weight: bold;
position: flex;
--duration: 10s;
animation: color-change var(--duration) infinite;
}
.awesome:nth-child(1) {
--color: red;
}
.awesome:nth-child(2) {
--color: blue;
animation-delay: calc(var(--duration) / 3)
}
.awesome:nth-child(3) {
--color: yellow;
animation-delay: calc(var(--duration) * 2 / 3);
}
#keyframes color-change {
0% {
color: var(--color);
}
30% {
color: var(--color);
}
33.3333% {
color: black;
}
100% {
color: black;
}
}
<div class='center'>
<p class="awesome">Develop</p>
<p class="awesome">Preview</p>
<p class="awesome">Ship</p>
</div>
I am trying to implement the typewriting effect on two lines for a webpage (black background), where I am not able to execute a cursor blinking once the second sentence has been typed out.
I have put out the HTML and CSS code. Any help in rectifying where I've gone wrong will be helpful.
HTML:
<div class="typewriter">
<h1>Hi,</h1>
<h2>This is <span style="color: orange">ABC.</span></h2></div>
CSS:
.typewriter h1 {
color: #fff;
font-family: 'DM Mono', monospace;
overflow: hidden;
font-size: 80px;
border-right: .15em solid black;
white-space: nowrap;
letter-spacing: .15em;
width: 4ch;
animation: typing 2.5s steps(4, end), blink-caret .75s step-end 4;
}
.typewriter h2 {
color: #fff;
font-family: 'DM Mono', monospace;
font-size: 40px;
white-space: nowrap;
overflow: hidden;
border-right: .15em solid orange;
width: 20ch;
animation: typing2 2s steps(20, end), blink-caret 1s step-end;
animation-delay: 3s;
animation-fill-mode: both;
}
#keyframes typing {
from {
width: 0
}
to {
width: 3em;
}
}
#keyframes typing2 {
from {
width: 0
}
to {
width: 20em;
}
}
#keyframes blink-caret {
from, to {
border-color: transparent
}
50% {
border-color: white;
}
}
I don't know why this works, but it works. Let me know if it gives the desired effect.
.typewriter h2 {
color: #fff;
font-family: 'DM Mono', monospace;
font-size: 40px;
white-space: nowrap;
overflow: hidden;
border-right: .15em solid orange;
//this is what i changed
width: 12ch;
animation: typing2 2s steps(12, end), blink-caret 1s step-end infinite;
////
animation-delay: 3s;
animation-fill-mode: both;
}
#keyframes typing2 {
from {
width: 0
}
to {
//this is what i changed
width: 12ch;
////
}
}
I'm trying to achieve a typing effect with multiple lines in CSS.
This was a good reference point I followed:
CSS animated typing
https://css-tricks.com/snippets/css/typewriter-effect/
Now my desired effect is that the first border-right's visibility be hidden once the first blinking cursor's animation ends. A the border-right is still on screen after the animation ends and I want it not to be visible. (As if enter button on a keyboard was pressed.) How would I go about that?
https://jsfiddle.net/6567onn8/5/
.typewriter h1 {
text-align: center;
overflow: hidden;
font-size: 100%;
border-right: .15em solid #fff;
white-space: nowrap;
/* keeps content in one line */
letter-spacing: .15em;
animation: typing 2.5s steps(22, end), blink-caret .75s step-end;
}
.typewriter h2 {
font-size: 100%;
white-space: nowrap;
overflow: hidden;
border-right: .15em solid black;
-webkit-animation: typing 2s steps(26, end), blink-caret 1s step-end infinite;
-webkit-animation-delay: 3s;
-webkit-animation-fill-mode: both;
-moz-animation: typing 2s steps(26, end), blink-caret 1s step-end infinite;
-moz-animation-delay: 3s;
}
/* The typing effect */
#keyframes typing {
from {
width: 0
}
to {
width: 9em;
}
}
#keyframes blink-caret {
from, to {
border-color: transparent
}
50% {
border-color: #000;
}
}
<div class="typewriter">
<h1>Hi. I'm Andy.</h1>
<h2>I love learning.</h2>
</div>
Just take out infinite
.typewriter h1 {
text-align: center;
overflow: hidden;
font-size: 100%;
border-right: .15em solid #fff;
white-space: nowrap;
/* keeps content in one line */
letter-spacing: .15em;
animation: typing 2.5s steps(22, end), blink-caret .75s step-end;
}
.typewriter h2 {
font-size: 100%;
white-space: nowrap;
overflow: hidden;
border-right: .15em solid black;
-webkit-animation: typing 2s steps(26, end), blink-caret 1s step-end;
-webkit-animation-delay: 3s;
-webkit-animation-fill-mode: both;
-moz-animation: typing 2s steps(26, end), blink-caret 1s step-end;
-moz-animation-delay: 3s;
}
/* The typing effect */
#keyframes typing {
from {
width: 0
}
to {
width: 9em;
}
}
#keyframes blink-caret {
from, to {
border-color: transparent
}
50% {
border-color: #000;
}
}
<div class="typewriter">
<h1>Hi. I'm Andy.</h1>
<h2>I love learning.</h2>
</div>
body{
margin: 0;
font-family: 'Pacifico', cursive;
}
.blackboard-wrapper {
width: 100vw;
height: 100vh;
background-image: repeating-linear-gradient(to bottom,#26180B 70%,#362418 77%,#77736A 78%,#655444 78%);
}
.black-board {
height: 360px;
width: 800px;
transform: translateY(70px);
margin: 0 auto;
background-image: repeating-linear-gradient(to bottom,#000000 77%,#111111 78%,#222222 77%,#000000 78%);
border-width: 15px;
border-style: groove;
border-color: #2E1E11;
position: relative;
color: #ffffff;
}
.date {
position: absolute;
left: 15px;
top: 10px;
}
.date > span {
display: block;
margin-bottom: 5px;
}
.black-board::before {
position: absolute;
left: 0;
content: "";
right: 0;
background-color: #afafaf;
height: 2px;
top: 94px;
}
.topic {
position: absolute;
top: 28px;
left: 50%;
transform: translateX(-50%);
text-decoration: underline;
word-spacing: 8px;
}
.writing {
position: absolute;
top: 120px;
left: 15px;
right: 15px;
bottom: 15px;
}
.writing::after,
.writing::before {
position: absolute;
letter-spacing: 2px;
font-size: 30px;
animation-name: write;
animation-duration: 5s;
animation-iteration-count: infinite;
animation-timing-function: cubic-bezier(.7,.45,.97,.36);
}
.writing::before{
font-size: 25px;
content:"This is cool NAAA???";
top: 70px;
color: #1FBEA6;
animation-name: write2;
animation-duration: 2s;
animation-iteration-count: 1;
animation-timing-function: cubic-bezier(.7,.45,.97,.36);
}
#keyframes write{
0%{content:"";}
3%{content:"V_";}
6%{content:"VI_";}
9%{content:"VIK_";}
12%{content:"VIKA_";}
15%,25%{content:"VIKAS";}
28%{content:"VIKA_";}
31%{content:"VIK_";}
34%{content:"VI_";}
37%{content:"V_";}
40%,50%{content:"";}
53%{content:"P_";}
56%{content:"PA_";}
59%{content:"PAT_";}
62%{content:"PATE_";}
65%,75%{content:"PATEL";}
78%{content:"PATE_";}
81%{content:"PAT_";}
84%{content:"PA_";}
88%{content:"P_";}
91%,100%{content:"";}
}
#keyframes write2{
0%{content:"";}
5%{content:"T_";}
10%{content:"Th_";}
15%{content:"Thi_";}
20%{content:"This_ ";}
25%{content:"This i_";}
30%{content:"This is_";}
35%{content:"This is_ ";}
40%{content:"This is c_";}
45%{content:"This is co_";}
50%{content:"This is coo_";}
55%{content:"This is cool_";}
65%{content:"This is cool N_";}
70%{content:"This is cool NA_";}
75%{content:"This is cool NAA_";}
80%{content:"This is cool NAAA";}
85%{content:"This is cool NAAA?";}
90%{content:"This is cool NAAA??";}
95%{content:"This is cool NAAA???";}
100%{content:"This is cool NAAA???";}
}
<link href="https://fonts.googleapis.com/css?family=Pacifico" rel="stylesheet">
<div class="blackboard-wrapper">
<div class="black-board">
<div class="date">
<span>DATE</span>
<span>25|oct|2018</span>
</div>
<div class="topic">TYPING EFFECT USING CSS</div>
<div class="writing"></div>
</div>
</div>
https://codepen.io/Vikaspatel/pen/mzarrO
.wrapper {
height: 100vh;
/*This part is important for centering*/
display: flex;
align-items: center;
justify-content: center;
}
.typing-demo {
width: 22ch;
animation: typing 2s steps(22), blink .5s step-end infinite alternate;
white-space: nowrap;
overflow: hidden;
border-right: 3px solid;
font-family: monospace;
font-size: 2em;
}
#keyframes typing {
from {
width: 0
}
}
#keyframes blink {
50% {
border-color: transparent
}
}
<div class="wrapper">
<div class="typing-demo">
This is a typing demo.
</div>
</div>
Easiest way of doing it in CSS.
I'm looking to add a blinking caret / cursor inside the form in a twitter bootstrap 3 site. There is a codepen for the html and css but I need help on where to add the code, if the code works with bootstrap? I'm new and eager to learn but I have browsed and browsed and got no results.
The codepen is here
http://codepen.io/ArtemGordinsky/pen/GnLBq
html
<span class="blinking-cursor">|</span>
css
.blinking-cursor {
font-weight: 100;
font-size: 30px;
color: #2E3D48;
-webkit-animation: 1s blink step-end infinite;
-moz-animation: 1s blink step-end infinite;
-ms-animation: 1s blink step-end infinite;
-o-animation: 1s blink step-end infinite;
animation: 1s blink step-end infinite;
}
#keyframes "blink" {
from, to {
color: transparent;
}
50% {
color: black;
}
}
#-moz-keyframes blink {
from, to {
color: transparent;
}
50% {
color: black;
}
}
#-webkit-keyframes "blink" {
from, to {
color: transparent;
}
50% {
color: black;
}
}
#-ms-keyframes "blink" {
from, to {
color: transparent;
}
50% {
color: black;
}
}
#-o-keyframes "blink" {
from, to {
color: transparent;
}
50% {
color: black;
}
}
Simply wrap the input and the blinking icon into a container, then position the blinking icon inside the input.
/* The container */
.input-container {
position: relative;
}
/* Ensure the font-size is the same as the blinking icon */
.input-container input {
border: 1px solid gray;
font-size: 30px;
padding:0 5px;
}
/* Position it where you want. Must be position: absolute! */
.input-container .blinking-cursor {
position: absolute;
left: 5px; /* The same as padding on the input */
}
/* This will hide the blinking cursor when the user clicks on the input */
.input-container input:focus + .blinking-cursor{
visibility: hidden;
}
/* The code below is from the codepen: http://codepen.io/ArtemGordinsky/pen/GnLBq */
.blinking-cursor {
font-weight: 100;
font-size: 30px;
color: #2E3D48;
-webkit-animation: 1s blink step-end infinite;
-moz-animation: 1s blink step-end infinite;
-ms-animation: 1s blink step-end infinite;
-o-animation: 1s blink step-end infinite;
animation: 1s blink step-end infinite;
}
#keyframes "blink" {
from, to {
color: transparent;
}
50% {
color: black;
}
}
#-moz-keyframes blink {
from, to {
color: transparent;
}
50% {
color: black;
}
}
#-webkit-keyframes "blink" {
from, to {
color: transparent;
}
50% {
color: black;
}
}
#-ms-keyframes "blink" {
from, to {
color: transparent;
}
50% {
color: black;
}
}
#-o-keyframes "blink" {
from, to {
color: transparent;
}
50% {
color: black;
}
}
<div class="input-container">
<input type="text">
<span class="blinking-cursor">|</span>
</div>
You may want to edit the styles further, but this will put you in the direction you're wanting to go.