Rainbow text animation using only CSS - html

I got inspired by this Rainbow Text Animation rainbow-text-animation, and I would like to use only CSS to make this happen instead of all that complicated SCSS coding.
I got what I like so far and now I just want to make it go from left to right AND having multiple colors in one entire line instead of one color at a time.
Run the code snippet to see what I'm talking about.
So as you can see, I want as many colors I want in one line and not one color in the entire line (one at a time).
#shadowBox {
background-color: rgb(0, 0, 0);
/* Fallback color */
background-color: rgba(0, 0, 0, 0.2);
/* Black w/opacity/see-through */
border: 3px solid;
}
.rainbow {
text-align: center;
text-decoration: underline;
font-size: 32px;
font-family: monospace;
letter-spacing: 5px;
animation: colorRotate 6s linear 0s infinite;
}
#keyframes colorRotate {
from {
color: #6666ff;
}
10% {
color: #0099ff;
}
50% {
color: #00ff00;
}
75% {
color: #ff3399;
}
100% {
color: #6666ff;
}
}
<div id="shadowBox">
<h3 class="rainbow">COMING SOON</h3>
</div>

You can achieve this effect by using a moving gradient background, color to transparent, and background clip to text.
#shadowBox {
background-color: rgb(0, 0, 0);
/* Fallback color */
background-color: rgba(0, 0, 0, 0.2);
/* Black w/opacity/see-through */
border: 3px solid;
}
.rainbow {
text-align: center;
text-decoration: underline;
font-size: 32px;
font-family: monospace;
letter-spacing: 5px;
}
.rainbow_text_animated {
background: linear-gradient(to right, #6666ff, #0099ff , #00ff00, #ff3399, #6666ff);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
animation: rainbow_animation 6s ease-in-out infinite;
background-size: 400% 100%;
}
#keyframes rainbow_animation {
0%,100% {
background-position: 0 0;
}
50% {
background-position: 100% 0;
}
}
<div id="shadowBox">
<h3 class="rainbow rainbow_text_animated">COMING SOON</h3>
</div>

#shadowBox {
background-color: rgb(0, 0, 0);
/* Fallback color */
background-color: rgba(0, 0, 0, 0.2);
/* Black w/opacity/see-through */
border: 3px solid;
}
.rainbow {
text-align: center;
text-decoration: underline;
font-size: 32px;
font-family: monospace;
letter-spacing: 5px;
animation: colorRotate .5s linear 0s infinite;
}
#keyframes colorRotate {
from {
color: #6666ff;
}
10% {
color: #0099ff;
}
50% {
color: #00ff00;
}
75% {
color: #ff3399;
}
100% {
color: #6666ff;
}
}
<div id="shadowBox">
<h3 class="rainbow">VERB</h3>
</div>

Related

Data-text attribute on an h1 element doesn't show up when adding an animation to the element

I have an h1 element that I want to be invisible and then appear after a few seconds. The element has an ::after pseudo-element that displays a data-text attribute that shadows the h1 element. When I add the animation, I only see the h1 and not the pseudo-element as well. Here is my code
EDIT
adding the animation to the pseudo-element makes it appear, but now the data-text appears over the h1 element when originally it is supposed to go behind it. Here are some pic of what is happening. The first is what it is doing and the second is what I want.
EDIT 2
The problem can be recreated by removing the z-index on the pseudo-element.
<section class="wrapper">
<div class="content-wrapper">
<img class="flipInY" src="./img/neon-blue - flip.png" alt="logo-triangle">
<h1 class="name-ani" data-text="My Name">My Name</h1>
<h2 data-text="web-dev">Web Developer</h2>
</div>
</section>
.wrapper {
.content-wrapper {
z-index: 0;
position: relative;
display: grid;
justify-items: center;
margin-top: 20vh;
img {
width: 350px;
max-width: 100%;
padding: 0 32px;
// transform: rotate(180deg);
filter: brightness(85%);
position: relative;
}
h1 {
background: linear-gradient(
to bottom,
#ebf1f6 0%,
#abd3ee 50%,
#859ee2 51%,
#d5ebfb 100%
);
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
font-family: kimberly;
text-transform: uppercase;
font-size: 2.25rem;
transition: font-size 1s;
position: absolute;
top: 10%;
opacity: 0;
&::after {
background: none;
content: attr(data-text);
left: 0;
position: absolute;
text-shadow: 1px -1px 0 rgba(255, 255, 255, 0.5),
3px 1px 3px rgba(255, 0, 255, 0.85),
-3px -2px 3px rgba(0, 0, 255, 0.85),
1px -2px 0 rgba(255, 255, 255, 0.8);
z-index: -10;
opacity: 0;
}
}
.name-ani {
animation-name: name-ani;
animation-duration: 250ms;
animation-delay: 4.5s;
animation-fill-mode: forwards;
}
#keyframes name-ani {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
You need to apply the animation to the pseudo-element as well.
.name-ani,
.name-ani::after {
animation-name: name-ani;
animation-duration: 250ms;
animation-delay: 4.5s;
animation-fill-mode: forwards;
}
Edit: Getting rid of the position: absolute on the h1 by wrapping it and giving it an display: inline solved the stacking order for me as well.
<section class="wrapper">
<div class="content-wrapper">
<img class="flipInY" src="./img/neon-blue - flip.png" alt="logo-triangle">
<div class="h1-wrapper">
<h1 class="name-ani" data-text="My Name">My Name</h1>
</div>
<h2 data-text="web-dev">Web Developer</h2>
</div>
</section>
.wrapper {
.content-wrapper {
z-index: 0;
position: relative;
display: grid;
justify-items: center;
margin-top: 20vh;
img {
width: 350px;
max-width: 100%;
padding: 0 32px;
filter: brightness(85%);
position: relative;
}
.h1-wrapper {
position: absolute;
top: 10%;
}
h1 {
background: linear-gradient(to bottom,
#ebf1f6 0%,
#abd3ee 50%,
#859ee2 51%,
#d5ebfb 100%);
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
font-family: kimberly;
text-transform: uppercase;
font-size: 2.25rem;
transition: font-size 1s;
display: inline;
opacity: 0;
&::after {
background: none;
content: attr(data-text);
left: 0;
position: absolute;
text-shadow: 1px -1px 0 rgba(255, 255, 255, 0.5),
3px 1px 3px rgba(255, 0, 255, 0.85),
-3px -2px 3px rgba(0, 0, 255, 0.85),
1px -2px 0 rgba(255, 255, 255, 0.8);
z-index: -10;
opacity: 0;
}
}
.name-ani,
.name-ani::after {
animation-name: name-ani;
animation-duration: 250ms;
animation-delay: 4.5s;
animation-fill-mode: forwards;
}
#keyframes name-ani {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
}
}

How to optimize css style for Safari

I had a problem with the correct display of css3 styles on Safari. Here is a link to my code: https://codepen.io/VictorHub/pen/NmYOGj There are transparent stroke text over image. Everything works well but not in Safari browser(There appears a black background in the letters). Naturally we are talking about the latest versions of the Safari browser. Please help me solve this issue. The situation is complicated by the fact that I do not have macos.
html {
background: #fff;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-image: url('https://medievaltorturemuseum.com/wp-content/uploads/2018/02/slide3-1.jpg')
}
.text-wrap {
mix-blend-mode: screen;
position: absolute;
}
.text {
text-align: center;
font-weight: 700;
color: rgb(12, 12, 12);
font-size: 98px;
background: -webkit-linear-gradient(top, rgba(170,26,24,1) 0%, rgba(213,44,50,1) 39%, rgba(236,97,94,1) 45%, rgba(202,34,34,1) 69%, rgba(148,36,43,1) 100%);
-webkit-background-clip: text;
-webkit-text-stroke: 4px transparent;
letter-spacing: -4px;
text-shadow: 0px 0px 20px rgba(208,34,40,1);
animation-name: blink2;
animation-duration: 150ms;
animation-iteration-count: infinite;
animation-direction: alternate;
-webkit-font-smoothing: antialiased !important;
}
#keyframes blink2 {
0% {
text-shadow: 0px 0px 20px rgba(208,34,40,1);
}
100% {
text-shadow: 0px 0px 20px rgba(208,34,40,0.75);
}
}
<div class="text-wrap">
<div class="text">ARE YOU BRAVE<br/>ENOUGH ?</div>
</div>
html {
background: #fff;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-image: url('https://medievaltorturemuseum.com/wp-content/uploads/2018/02/slide3-1.jpg')
}
.text-wrap {
mix-blend-mode: screen;
position: absolute;
}
.text {
text-align: center;
font-weight: 700;
color: rgb(12, 12, 12);
font-size: 98px;
background: -webkit-linear-gradient(top, rgba(170,26,24,1) 0%, rgba(213,44,50,1) 39%, rgba(236,97,94,1) 45%, rgba(202,34,34,1) 69%, rgba(148,36,43,1) 100%);
-webkit-background-clip: text;
-webkit-text-stroke: 4px transparent;
letter-spacing: -4px;
text-shadow: 0px 0px 20px rgba(208,34,40,1);
animation-name: blink2;
animation-duration: 150ms;
animation-iteration-count: infinite;
animation-direction: alternate;
-webkit-font-smoothing: antialiased !important;
}
#keyframes blink2 {
0% {
text-shadow: 0px 0px 20px rgba(208,34,40,1);
}
100% {
text-shadow: 0px 0px 20px rgba(208,34,40,0.75);
}
}
#-webkit-keyframes blink2 {
0% {
text-shadow: 0px 0px 20px rgba(208,34,40,1);
}
100% {
text-shadow: 0px 0px 20px rgba(208,34,40,0.75);
}
}
#-moz-keyframes blink2 {
0% {
text-shadow: 0px 0px 20px rgba(208,34,40,1);
}
100% {
text-shadow: 0px 0px 20px rgba(208,34,40,0.75);
}
}
#-o-keyframes blink2 {
0% {
text-shadow: 0px 0px 20px rgba(208,34,40,1);
}
100% {
text-shadow: 0px 0px 20px rgba(208,34,40,0.75);
}
}
<div class="text-wrap">
<div class="text">ARE YOU BRAVE<br/>ENOUGH ?</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;

Button not getting positioned

body {
background-image: url("http://www.nozeens.com/wp-content/uploads/2014/11/White-Wallpaper-Pattern-Hd-Background-8-HD-Wallpapers.jpg");
}
.button {
margin-top: 100px;
position: relative;
background: -webkit-linear-gradient(left top, #FF6600, #FFCC00);
/* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
-webkit-transition-duration: 0.4s;
/* Safari */
transition-duration: 4s;
}
#-webkit-keyframes color-change {
0% {
background: -webkit-linear-gradient(left top, #005C66, #008A19);
}
25% {
background: -webkit-linear-gradient(left top, #CC66FF, #990099);
}
50% {
background: -webkit-linear-gradient(left top, #FF8C9E, #FFF2C7);
}
75% {
background: -webkit-linear-gradient(left top, #00A3C7, #00C7B5);
}
100% {
background: -webkit-linear-gradient(left top, #ABFF54, #75FF8A);
}
}
.button2:hover {
height: 250px;
min-width: 200px;
font-size: 75px;
font-family: american captain;
box-shadow: 0 12px 16px 0 rgba(0, 0, 0, 0.24), 0 17px 50px 0 rgba(0, 0, 0, 0.19);
transform: rotate(360deg);
animation: color-change 4s ease infinite;
}
<button class="button button2">Hover Me For Fun</button>
I created this animated button with the animations i just learnt but I can't seem to position it i even tried putting margin-top but it didn't work. At first I thought that it was because of position so I changed it to relative but it is still not working. Any help would be highly appreciated. Thanks :-)

Making smoothly animated striped div

I'm having trouble making a smoothly animated striped div, like a progress bar.
CSS:
.animationStripes{
width: 300px;
height: 50px;
background-image: repeating-linear-gradient(-45deg, rgb(0, 0, 0), rgb(0, 0, 0) 25px, blue 25px, blue 50px);
-webkit-animation:progress 2s linear infinite;
-moz-animation:progress 2s linear infinite;
-ms-animation:progress 2s linear infinite;
animation:progress 2s linear infinite;
}
#keyframes progress{
0% {
background-position: 0 0;
}
100% {
background-position: -70px 0px;
}
}
http://plnkr.co/edit/4wPv1ogKNMfJ6rQPhZdJ?p=preview
The problem is that there is a weird misalignment on the very right side of the background image gradient. How do i fix this misalignment?
Have you seen this tutorial on CSS Tricks?
#import url(https://fonts.googleapis.com/css?family=Ropa+Sans);
body {
padding: 20px;
font-family: 'Ropa Sans', sans-serif;
}
.product {
width: 376px;
padding: 15px;
position: relative;
float: left;
margin: 0 20px 0 0;
}
.product>img {
display: block;
position: relative;
}
.product:hover .product-hover,
.product:active .product-hover {
opacity: 1;
}
.product-hover {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
opacity: 0;
transition: opacity 0.3s ease;
background-size: 30px 30px;
background-image: linear-gradient(45deg, rgba(0, 0, 0, 0.1) 25%, transparent 25%, transparent 50%, rgba(0, 0, 0, 0.1) 50%, rgba(0, 0, 0, 0.1) 75%, transparent 75%, transparent);
animation: barberpole 0.5s linear infinite;
}
#keyframes barberpole {
from {
background-position: 0 0;
}
to {
background-position: 60px 30px;
}
}
.product-info {
position: absolute;
bottom: 30px;
right: 30px;
background: white;
width: 150px;
padding: 10px 10px 50px 10px;
}
.subhead {
color: #f00;
text-transform: uppercase;
font-weight: bold;
}
.product-name {
color: #990033;
text-transform: uppercase;
font-weight: bold;
margin: 0;
letter-spacing: -1px;
}
.price {
position: absolute;
bottom: 10px;
right: 10px;
}
.amount {
color: red;
font-size: 150%;
}
.amount>span {
font-size: 75%;
}
h1 {
font-size: 72px;
margin: 2px 0 0 0;
}
VIEW SCSS CODE
<div class="product">
<div class="product-hover"></div> <img src="http://fillmurray.com/300/300" />
<div class="product-info">
<div class="subhead">Sale</div>
<h2 class="product-name">Fleece</h2>
<p class="product-description">Beat the chill and get cozy.</p>
<div class="price"> <span class="from">from</span> <span class="amount"> <span>$</span>9.90 </span>
</div>
</div>
</div>
Well I managed to fix it just by adding one thing and making no alterations to my original code. Simply adding background-size: 150% 100%; kept the image from clipping awkwardly on the right side.
http://plnkr.co/edit/4wPv1ogKNMfJ6rQPhZdJ?p=preview
Make the linear gradient with percentage values, not with pixel. apply background-size, in your case i'd say background-size:50px 50px; and in keyframes, move the background as much, as is the background size background-position: -50px 0px;
Also an example
http://plnkr.co/edit/HrSxkhYZaWp81fAQEaJn?p=preview
If the answer suits you, then mark it as answered and have a good day :)