Animate the colour of icons in a rainbow pattern - html

How do I make font awesome icons change colour automatically like rainbow. In my current code, the text is changing colours but I want the icon to change colours too.
You can find a code example here:
#import url(https://fonts.googleapis.com/css?family=Pacifico);
#import url('https://fonts.googleapis.com/css?family=Anton');
h1, h2{
text-align:center;
}
h1{
color:rgba(100, 50, 255, .8);
font-family: 'Pacifico', cursive;
color:#212121;
}
.rainbow {
/* Font options */
font-family: 'Pacifico', cursive;
text-shadow: 2px 2px 4px #000000;
font-size:40px;
/* Chrome, Safari, Opera */
-webkit-animation: rainbow 5s infinite;
/* Internet Explorer */
-ms-animation: rainbow 5s infinite;
/* Standar Syntax */
animation: rainbow 5s infinite;
}
/* Chrome, Safari, Opera */
#-webkit-keyframes rainbow{
0%{color: orange;}
10%{color: purple;}
20%{color: red;}
30%{color: CadetBlue;}
40%{color: yellow;}
50%{color: coral;}
60%{color: green;}
70%{color: cyan;}
80%{color: DeepPink;}
90%{color: DodgerBlue;}
100%{color: orange;}
}
/* Internet Explorer */
#-ms-keyframes rainbow{
0%{color: orange;}
10%{color: purple;}
20%{color: red;}
30%{color: CadetBlue;}
40%{color: yellow;}
50%{color: coral;}
60%{color: green;}
70%{color: cyan;}
80%{color: DeepPink;}
90%{color: DodgerBlue;}
100%{color: orange;}
}
/* Standar Syntax */
#keyframes rainbow{
0%{color: orange;}
10%{color: purple;}
20%{color: red;}
30%{color: CadetBlue;}
40%{color: yellow;}
50%{color: coral;}
60%{color: green;}
70%{color: cyan;}
80%{color: DeepPink;}
90%{color: DodgerBlue;}
100%{color: orange;}
}
body{
background-color:#607D8B;
}
.container{
background-color:#E0F2F1;
padding:10px;
border-radius:15px;
box-shadow: 10px 10px 20px 0px rgba(0,0,0,0.75);
}
<div class="container">
<h1>SIMPLE CSS RAINBOW TEXT</h1>
<h2 class="rainbow">Rainbow Text</h2>
</div>

Below you can see that I just reused your code to change the color of a font awesome icon.
Changing color of a font awesome icon is similar to that of a text, i.e. using color
In the below snippet I just assigned the class rainbow to the font awesome icon.
.rainbow {
/* Chrome, Safari, Opera */
-webkit-animation: rainbow 5s infinite;
/* Internet Explorer */
-ms-animation: rainbow 5s infinite;
/* Standar Syntax */
animation: rainbow 5s infinite;
}
/* Chrome, Safari, Opera */
#-webkit-keyframes rainbow {
0% {
color: orange;
transform: rotate(360deg);
}
10% {
color: purple;
}
20% {
color: red;
}
30% {
color: CadetBlue;
}
40% {
color: yellow;
}
50% {
color: coral;
}
60% {
color: green;
}
70% {
color: cyan;
}
80% {
color: DeepPink;
}
90% {
color: DodgerBlue;
}
100% {
color: orange;
}
}
/* Internet Explorer */
#-ms-keyframes rainbow {
0% {
color: orange;
transform: rotate(360deg);
}
10% {
color: purple;
}
20% {
color: red;
}
30% {
color: CadetBlue;
}
40% {
color: yellow;
}
50% {
color: coral;
}
60% {
color: green;
}
70% {
color: cyan;
}
80% {
color: DeepPink;
}
90% {
color: DodgerBlue;
}
100% {
color: orange;
}
}
/* Standar Syntax */
#keyframes rainbow {
0% {
color: orange;
transform: rotate(360deg);
}
10% {
color: purple;
}
20% {
color: red;
}
30% {
color: CadetBlue;
}
40% {
color: yellow;
}
50% {
color: coral;
}
60% {
color: green;
}
70% {
color: cyan;
}
80% {
color: DeepPink;
}
90% {
color: DodgerBlue;
}
100% {
color: orange;
}
}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css">
<i class="fas fa-exclamation-triangle rainbow fa-7x"></i>
EDIT: Updated the post to answer OP's second question which is in the comment section'

Just give a class of rainbow:
#import url(https://fonts.googleapis.com/css?family=Pacifico);
#import url('https://fonts.googleapis.com/css?family=Anton');
h1,
h2 {
text-align: center;
}
h1 {
color: rgba(100, 50, 255, .8);
font-family: 'Pacifico', cursive;
color: #212121;
}
.rainbow {
/* Font options */
font-family: 'Pacifico', cursive;
text-shadow: 2px 2px 4px #000000;
font-size: 40px;
/* Chrome, Safari, Opera */
-webkit-animation: rainbow 5s infinite;
/* Internet Explorer */
-ms-animation: rainbow 5s infinite;
/* Standar Syntax */
animation: rainbow 5s infinite;
}
/* Chrome, Safari, Opera */
#-webkit-keyframes rainbow {
0% {
color: orange;
}
10% {
color: purple;
}
20% {
color: red;
}
30% {
color: CadetBlue;
}
40% {
color: yellow;
}
50% {
color: coral;
}
60% {
color: green;
}
70% {
color: cyan;
}
80% {
color: DeepPink;
}
90% {
color: DodgerBlue;
}
100% {
color: orange;
}
}
/* Internet Explorer */
#-ms-keyframes rainbow {
0% {
color: orange;
}
10% {
color: purple;
}
20% {
color: red;
}
30% {
color: CadetBlue;
}
40% {
color: yellow;
}
50% {
color: coral;
}
60% {
color: green;
}
70% {
color: cyan;
}
80% {
color: DeepPink;
}
90% {
color: DodgerBlue;
}
100% {
color: orange;
}
}
/* Standar Syntax */
#keyframes rainbow {
0% {
color: orange;
}
10% {
color: purple;
}
20% {
color: red;
}
30% {
color: CadetBlue;
}
40% {
color: yellow;
}
50% {
color: coral;
}
60% {
color: green;
}
70% {
color: cyan;
}
80% {
color: DeepPink;
}
90% {
color: DodgerBlue;
}
100% {
color: orange;
}
}
body {
background-color: #607D8B;
}
.container {
background-color: #E0F2F1;
padding: 10px;
border-radius: 15px;
box-shadow: 10px 10px 20px 0px rgba(0, 0, 0, 0.75);
}
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<div class="rainbow">
<section id="hand">
<div class="row fontawesome-icon-list">
<div class="fa-hover col-md-3 col-sm-4"><i class="rainbow fa fa-hand-grab-o" aria-hidden="true"></i> <span class="sr-only">Example of </span>hand-grab-o <span class="text-muted">(alias)</span></div>
</div>

Related

Looping Animation of text color change in multiple elements (text) using CSS3

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>

css typing blink animation

I have made a typing animation in CSS. I have an issue with the letter not showing up fully.
Trying to make "m" as one letter, Also animation to feel more natural. It needs to look like someone is typing.
need help to animate each letter in the "remirror" separately and make it look like someone is typing so each key comes in slightly off time.
https://codepen.io/shahil/pen/ZEGwMxQ
#font-face {
font-family: danub;
src: url(https://cdn.getforge.com/remirror.getforge.io/1585586993/danub.ttf);
}
#-webkit-keyframes typing {
from {
width: 0;
}
to {
width: 16.3em;
}
}
#-moz-keyframes typing {
from {
width: 0;
}
to {
width: 16.3em;
}
}
#-webkit-keyframes blink-caret {
from,
to {
border-color: transparent;
}
50% {
border-color: black;
}
}
#-moz-keyframes blink-caret {
from,
to {
border-color: transparent;
}
50% {
border-color: black;
}
}
body {
font-family: Consolas, monospace;
}
h1 {
font-size: 3rem;
width: 16.3em;
white-space: nowrap;
overflow: hidden;
color: #000;
border-right: 0.1em solid black;
font-family: danub;
-webkit-animation: typing 17s steps(30, end),
/* # of steps = # of characters */ blink-caret 1s step-end infinite;
}
<h1>remirror</h1>
If the word won't change you can try animating the content property of a pseudo-Element.
#font-face {
font-family: danub;
src: url(https://cdn.getforge.com/remirror.getforge.io/1585586993/danub.ttf);
}
/* For the caret */
h1:before {
content: '';
}
/* For the word */
h1:after {
content: '';
font-family: danub;
border-right: 0.1em solid black;
animation: typing 3s steps(8) forwards, blink-caret 1s step-end infinite;
}
#keyframes typing {
0% {
content: ''
}
12.5% {
content: 'r'
}
25% {
content: 're'
}
37.5% {
content: 'rem'
}
50% {
content: 'remi'
}
62.5% {
content: 'remir'
}
75% {
content: 'remirr'
}
87.5% {
content: 'remirro'
}
100% {
content: 'remirror'
}
}
#keyframes blink-caret {
from,
to {
border-color: transparent;
}
50% {
border-color: black;
}
}
<h1></h1>
Here is a crazy idea relying on background and box-decoration trick. It can also work with any kind of font-family:
#font-face {
font-family: danub;
src: url(https://cdn.getforge.com/remirror.getforge.io/1585586993/danub.ttf);
}
h1 {
font-size: 3rem;
height:1.1em; /* Same a gradient height */
line-height:1.3em; /* to rectify the oveflow (bigger than the height) */
word-break: break-all; /* This is the most important trick */
overflow: hidden; /* hide the line break */
font-family: danub;
animation:typing 10s linear forwards;
}
h1 span{
/* padding same as gradient width */
padding-right:0.1em; /* width height */
background:linear-gradient(red,red) right/ 0.1em 1.1em no-repeat;
-webkit-box-decoration-break:clone;
box-decoration-break:clone;
animation:blink-caret 0.5s infinite forwards;
}
#keyframes typing {
from {
max-width: 1em;
}
to {
max-width:100%;
}
}
#keyframes blink-caret {
to {
/* we change the gradient to transparent */
background-image:linear-gradient(transparent,transparent);
}
}
<h1><span>remirror text</span></h1>
<h1 style="font-family:arial"><span>another text here</span></h1>
To udnerstand the trick remove the overflow to see how the gradient behave with box-decoration:
#font-face {
font-family: danub;
src: url(https://cdn.getforge.com/remirror.getforge.io/1585586993/danub.ttf);
}
h1 {
font-size: 3rem;
height:1.1em; /* Same a gradient height */
line-height:1.2em; /* to rectify the oveflow */
word-break: break-all; /* This is the most important trick */
font-family: danub;
animation:typing 25s linear forwards;
border:1px solid;
}
h1 span{
padding-right:0.1em; /* width height */
background:linear-gradient(red,red) right/ 0.1em 1.1em no-repeat;
-webkit-box-decoration-break:clone;
box-decoration-break:clone;
}
#keyframes typing {
from {
max-width: 1em;
}
to {
max-width:100%;
}
}
<h1><span>remirror text</span></h1>

Rainbow text animation using only CSS

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>

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;

How can I add a link to the <i> tag?

I try to style some tags to get some good-looking social media buttons.
This is my current code:
#import url("//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css");
/* General rule */
.dist {
margin-left: 7px;
}
.button-big {
font-size: 2em;
width: 50px;
text-align: center;
padding: 0.2em 0em 0.2em 0em;
display: inline-block;
}
/* Facebook class and animation */
.facebook {
color: #3B5998;
border: 1px solid #3B5998;
}
.facebook:hover {
animation: facebookAnim 0.4s normal forwards linear;
-webkit-animation: facebookAnim 0.4s normal forwards linear;
}
#keyframes facebookAnim {
50% {
background-color: #3B5998;
}
100% {
background-color: #3B5998;
border: 1px solid #3B5998;
color: #fff;
}
}
#-webkit-keyframes facebookAnim {
50% {
background-color: #3B5998;
}
100% {
background-color: #3B5998;
border: 1px solid #3B5998;
color: #fff;
}
}
/* YouTube class and animation */
.youtube {
color: #bb0000;
border: 1px solid #bb0000;
}
.youtube:hover {
animation: youtubeAnim 0.4s normal forwards linear;
-webkit-animation: youtubeAnim 0.4s normal forwards linear;
}
#keyframes youtubeAnim {
50% {
background-color: #bb0000;
}
100% {
background-color: #bb0000;
border: 1px solid #bb0000;
color: #fff;
}
}
#-webkit-keyframes youtubeAnim {
50% {
background-color: #bb0000;
}
100% {
background-color: #bb0000;
border: 1px solid #bb0000;
color: #fff;
}
}
/* Instagram class and animation */
.instagram {
color: #125688;
border: 1px solid #125688;
}
.instagram:hover {
animation: instaAnim 0.4s normal forwards linear;
-webkit-animation: instaAnim 0.4s normal forwards linear;
}
#-webkit-keyframes instaAnim {
50% {
background-color: #125688;
}
100% {
background-color: #125688;
border: 1px solid #125688;
color: #fff;
}
}
#keyframes instaAnim {
50% {
background-color: #125688;
}
100% {
background-color: #125688;
border: 1px solid #125688;
color: #fff;
}
}
/* link style */
.facebook a {
color: #3B5998;
}
.youtube a {
color: #bb0000;
}
.instagram a {
color: #125688;
}
.facebook a:hover {
color: #fff;
}
.youtube a:hover {
color: #fff;
}
.instagram a:hover {
color: #fff;
}
<div class="facebook button-big">
<i class="fa fa-facebook"></i>
</div>
<div class="youtube button-big dist">
<i class="fa fa-youtube"></i>
</div>
<div class="instagram button-big dist">
<i class="fa fa-instagram"></i>
</div>
The problem is that the links is just on the icon, so when I hover the button a bit outside, the icon is style in the old color and not white. I hope you get what I mean, just have a look please.
How can I fix this the best way?
Encapsulate the divs in the a tags.
Add some styling to the a tag.
#import url("//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css");
/* General rule */
a {
text-decoration: none;
}
.dist {
margin-left: 7px;
}
.button-big {
font-size: 2em;
width: 50px;
text-align: center;
padding: 0.2em 0em 0.2em 0em;
display: inline-block;
}
/* Facebook class and animation */
.facebook {
color: #3B5998;
border: 1px solid #3B5998;
}
.facebook:hover {
animation: facebookAnim 0.4s normal forwards linear;
-webkit-animation: facebookAnim 0.4s normal forwards linear;
}
#keyframes facebookAnim {
50% {
background-color: #3B5998;
}
100% {
background-color: #3B5998;
border: 1px solid #3B5998;
color: #fff;
}
}
#-webkit-keyframes facebookAnim {
50% {
background-color: #3B5998;
}
100% {
background-color: #3B5998;
border: 1px solid #3B5998;
color: #fff;
}
}
/* YouTube class and animation */
.youtube {
color: #bb0000;
border: 1px solid #bb0000;
}
.youtube:hover {
animation: youtubeAnim 0.4s normal forwards linear;
-webkit-animation: youtubeAnim 0.4s normal forwards linear;
}
#keyframes youtubeAnim {
50% {
background-color: #bb0000;
}
100% {
background-color: #bb0000;
border: 1px solid #bb0000;
color: #fff;
}
}
#-webkit-keyframes youtubeAnim {
50% {
background-color: #bb0000;
}
100% {
background-color: #bb0000;
border: 1px solid #bb0000;
color: #fff;
}
}
/* Instagram class and animation */
.instagram {
color: #125688;
border: 1px solid #125688;
}
.instagram:hover {
animation: instaAnim 0.4s normal forwards linear;
-webkit-animation: instaAnim 0.4s normal forwards linear;
}
#-webkit-keyframes instaAnim {
50% {
background-color: #125688;
}
100% {
background-color: #125688;
border: 1px solid #125688;
color: #fff;
}
}
#keyframes instaAnim {
50% {
background-color: #125688;
}
100% {
background-color: #125688;
border: 1px solid #125688;
color: #fff;
}
}
/* link style */
.facebook a {
color: #3B5998;
}
.youtube a {
color: #bb0000;
}
.instagram a {
color: #125688;
}
.facebook a:hover {
color: #fff;
}
.youtube a:hover {
color: #fff;
}
.instagram a:hover {
color: #fff;
}
<a href="#">
<div class="facebook button-big">
<i class="fa fa-facebook"></i>
</div>
</a>
<a href="#">
<div class="youtube button-big dist">
<i class="fa fa-youtube"></i>
</div>
</a>
<a href="#">
<div class="instagram button-big dist">
<i class="fa fa-instagram"></i>
</div>
</a>
Another solution is to change the links color when you hover the button, like this:
.facebook:hover a {
color: #fff;
}
.youtube:hover a {
color: #fff;
}
.instagram:hover a {
color: #fff;
}
Full snippet:
#import url("//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css");
/* General rule */
.dist {
margin-left: 7px;
}
.button-big {
font-size: 2em;
width: 50px;
text-align: center;
padding: 0.2em 0em 0.2em 0em;
display: inline-block;
}
/* Facebook class and animation */
.facebook {
color: #3B5998;
border: 1px solid #3B5998;
}
.facebook:hover {
animation: facebookAnim 0.4s normal forwards linear;
-webkit-animation: facebookAnim 0.4s normal forwards linear;
}
#keyframes facebookAnim {
50% {
background-color: #3B5998;
}
100% {
background-color: #3B5998;
border: 1px solid #3B5998;
color: #fff;
}
}
#-webkit-keyframes facebookAnim {
50% {
background-color: #3B5998;
}
100% {
background-color: #3B5998;
border: 1px solid #3B5998;
color: #fff;
}
}
/* YouTube class and animation */
.youtube {
color: #bb0000;
border: 1px solid #bb0000;
}
.youtube:hover {
animation: youtubeAnim 0.4s normal forwards linear;
-webkit-animation: youtubeAnim 0.4s normal forwards linear;
}
#keyframes youtubeAnim {
50% {
background-color: #bb0000;
}
100% {
background-color: #bb0000;
border: 1px solid #bb0000;
color: #fff;
}
}
#-webkit-keyframes youtubeAnim {
50% {
background-color: #bb0000;
}
100% {
background-color: #bb0000;
border: 1px solid #bb0000;
color: #fff;
}
}
/* Instagram class and animation */
.instagram {
color: #125688;
border: 1px solid #125688;
}
.instagram:hover {
animation: instaAnim 0.4s normal forwards linear;
-webkit-animation: instaAnim 0.4s normal forwards linear;
}
#-webkit-keyframes instaAnim {
50% {
background-color: #125688;
}
100% {
background-color: #125688;
border: 1px solid #125688;
color: #fff;
}
}
#keyframes instaAnim {
50% {
background-color: #125688;
}
100% {
background-color: #125688;
border: 1px solid #125688;
color: #fff;
}
}
/* link style */
.facebook a {
color: #3B5998;
}
.youtube a {
color: #bb0000;
}
.instagram a {
color: #125688;
}
.facebook:hover a {
color: #fff;
}
.youtube:hover a {
color: #fff;
}
.instagram:hover a {
color: #fff;
}
<div class="facebook button-big">
<i class="fa fa-facebook"></i>
</div>
<div class="youtube button-big dist">
<i class="fa fa-youtube"></i>
</div>
<div class="instagram button-big dist">
<i class="fa fa-instagram"></i>
</div>
It is possible.
Try this code in your css:
.button-big:hover a i {
color: #fff;
}
As a quick fix, you could just inherit animation:
.button-big a , a i {
animation:inherit;
}
#import url("//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css");
/* General rule */
.dist {
margin-left: 7px;
}
.button-big {
font-size: 2em;
width: 50px;
text-align: center;
padding: 0.2em 0em 0.2em 0em;
display: inline-block;
}
/* Facebook class and animation */
.facebook {
color: #3B5998;
border: 1px solid #3B5998;
}
.facebook:hover {
animation: facebookAnim 0.4s normal forwards linear;
-webkit-animation: facebookAnim 0.4s normal forwards linear;
}
#keyframes facebookAnim {
50% {
background-color: #3B5998;
}
100% {
background-color: #3B5998;
border: 1px solid #3B5998;
color: #fff;
}
}
#-webkit-keyframes facebookAnim {
50% {
background-color: #3B5998;
}
100% {
background-color: #3B5998;
border: 1px solid #3B5998;
color: #fff;
}
}
/* YouTube class and animation */
.youtube {
color: #bb0000;
border: 1px solid #bb0000;
}
.youtube:hover {
animation: youtubeAnim 0.4s normal forwards linear;
-webkit-animation: youtubeAnim 0.4s normal forwards linear;
}
#keyframes youtubeAnim {
50% {
background-color: #bb0000;
}
100% {
background-color: #bb0000;
border: 1px solid #bb0000;
color: #fff;
}
}
#-webkit-keyframes youtubeAnim {
50% {
background-color: #bb0000;
}
100% {
background-color: #bb0000;
border: 1px solid #bb0000;
color: #fff;
}
}
/* Instagram class and animation */
.instagram {
color: #125688;
border: 1px solid #125688;
}
.instagram:hover {
animation: instaAnim 0.4s normal forwards linear;
-webkit-animation: instaAnim 0.4s normal forwards linear;
}
#-webkit-keyframes instaAnim {
50% {
background-color: #125688;
}
100% {
background-color: #125688;
border: 1px solid #125688;
color: #fff;
}
}
#keyframes instaAnim {
50% {
background-color: #125688;
}
100% {
background-color: #125688;
border: 1px solid #125688;
color: #fff;
}
}
/* link style */
.facebook a {
color: #3B5998;
}
.youtube a {
color: #bb0000;
}
.instagram a {
color: #125688;
}
.facebook a:hover {
color: #fff;
}
.youtube a:hover {
color: #fff;
}
.instagram a:hover {
color: #fff;
}
.button-big a , a i {
animation:inherit;
}
<div class="facebook button-big">
<i class="fa fa-facebook"></i>
</div>
<div class="youtube button-big dist">
<i class="fa fa-youtube"></i>
</div>
<div class="instagram button-big dist">
<i class="fa fa-instagram"></i>
</div>
Or color
.button-big a , a i {
color:inherit;
}
#import url("//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css");
/* General rule */
.dist {
margin-left: 7px;
}
.button-big {
font-size: 2em;
width: 50px;
text-align: center;
padding: 0.2em 0em 0.2em 0em;
display: inline-block;
}
/* Facebook class and animation */
.facebook {
color: #3B5998;
border: 1px solid #3B5998;
}
.facebook:hover {
animation: facebookAnim 0.4s normal forwards linear;
-webkit-animation: facebookAnim 0.4s normal forwards linear;
}
#keyframes facebookAnim {
50% {
background-color: #3B5998;
}
100% {
background-color: #3B5998;
border: 1px solid #3B5998;
color: #fff;
}
}
#-webkit-keyframes facebookAnim {
50% {
background-color: #3B5998;
}
100% {
background-color: #3B5998;
border: 1px solid #3B5998;
color: #fff;
}
}
/* YouTube class and animation */
.youtube {
color: #bb0000;
border: 1px solid #bb0000;
}
.youtube:hover {
animation: youtubeAnim 0.4s normal forwards linear;
-webkit-animation: youtubeAnim 0.4s normal forwards linear;
}
#keyframes youtubeAnim {
50% {
background-color: #bb0000;
}
100% {
background-color: #bb0000;
border: 1px solid #bb0000;
color: #fff;
}
}
#-webkit-keyframes youtubeAnim {
50% {
background-color: #bb0000;
}
100% {
background-color: #bb0000;
border: 1px solid #bb0000;
color: #fff;
}
}
/* Instagram class and animation */
.instagram {
color: #125688;
border: 1px solid #125688;
}
.instagram:hover {
animation: instaAnim 0.4s normal forwards linear;
-webkit-animation: instaAnim 0.4s normal forwards linear;
}
#-webkit-keyframes instaAnim {
50% {
background-color: #125688;
}
100% {
background-color: #125688;
border: 1px solid #125688;
color: #fff;
}
}
#keyframes instaAnim {
50% {
background-color: #125688;
}
100% {
background-color: #125688;
border: 1px solid #125688;
color: #fff;
}
}
/* link style */
.facebook a {
color: #3B5998;
}
.youtube a {
color: #bb0000;
}
.instagram a {
color: #125688;
}
.facebook a:hover {
color: #fff;
}
.youtube a:hover {
color: #fff;
}
.instagram a:hover {
color: #fff;
}
.button-big a , a i {
color:inherit;
}
<div class="facebook button-big">
<i class="fa fa-facebook"></i>
</div>
<div class="youtube button-big dist">
<i class="fa fa-youtube"></i>
</div>
<div class="instagram button-big dist">
<i class="fa fa-instagram"></i>
</div>