CSS not applying on icons - html

I'm watching Traversy Media's SASS Course, and I've got this problem with my icon colour not applying. Here's my HTML:
Does anyone know why the #fff colour isn't applying to my icons?
.icons a {
color: pink;
margin: 0 0.3rem;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" integrity="sha512-1ycn6IcaQQ40/MKBW2W4Rhis/DbILU74C1vSrLJxCq57o941Ym01SwNsOMqvEBFlcgUa6xLiPY/NS5R+E6ztJQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<div class="icons my-1">
<i class="fas fa-globe fa-2x"></i>
<i class="fab fa-twitter fa-2x"></i>
<i class="fab fa-facebook fa-2x"></i>
<i class="fab fa-linkedin fa-2x"></i>
<i class="fab fa-instagram fa-2x"></i>
</div>

You're applying the color to the surround <a> tag, to apply the effect to the inner <i> field you need the following CSS selector:
.icons a i {
color: #fff
}
Otherwise the selector is trying to change the color of the anchor itself, which has no color.

You need to apply the color to the element
.icons a i {
color: #fff;
}

try this:
.icons.my-1 a {
color: white;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" integrity="sha512-1ycn6IcaQQ40/MKBW2W4Rhis/DbILU74C1vSrLJxCq57o941Ym01SwNsOMqvEBFlcgUa6xLiPY/NS5R+E6ztJQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<div class="icons my-1">
<i class="fas fa-globe fa-2x"></i>
<i class="fab fa-twitter fa-2x"></i>
<i class="fab fa-facebook fa-2x"></i>
<i class="fab fa-linkedin fa-2x"></i>
<i class="fab fa-instagram fa-2x"></i>
</div>

I don't know why, but nothing was working out, anyways thanks for your help, I just copy pasted the source code from Traversy Media's YouTube Video which is extremely frustrating but can't be helped! Thanks!!

Related

Font Awesome 5, Why the instagram icon is missing?

why there is no instagram icon here
.share{
display:inline-block;
color:#0099cc;
font-size:25px;
}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css">
<i class="fab fa-facebook-square share"></i>
<i class="fab fa-instagram-square share"></i>
<i class="fab fa-twitter-square share"></i>
Update the version of the CDN to the lastest one. It was not there in 5.7 and was add starting from 5.12 (https://github.com/FortAwesome/Font-Awesome/blob/master/CHANGELOG.md#5121---2020-02-04)
Added
instagram-square icon FortAwesome/Font-Awesome#9223
.share {
display: inline-block;
color: #0099cc;
font-size: 25px;
}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.1/css/all.css">
<i class="fab fa-facebook-square share"></i>
<i class="fab fa-instagram-square share"></i>
<i class="fab fa-twitter-square share"></i>
It seems that fa-instagram-square isn't a part of your .css file.
Please use https://use.fontawesome.com/releases/v5.14.0/css/all.css that includes the fa-instagram-square icon.
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.14.0/css/all.css">
<i class="fab fa-facebook-square share"></i>
<i class="fab fa-instagram-square share"></i>
<i class="fab fa-twitter-square share"></i>
You need to update the cdn version to the latest v5.15.1 since the instagram-square has been introduced in later versions.
.share{
display:inline-block;
color:#0099cc;
font-size:25px;
}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.1/css/all.css">
<i class="fab fa-facebook-square share"></i>
<i class="fab fa-instagram-square share"></i>
<i class="fab fa-twitter-square share"></i>

Facebook and Twitter icons don't work, others do

Font Awesome is installed, and most icons work. Facebook and Twitter icons, however, do not.
I have tried changing the fa class to fab, and vice versa: neither work.
Here is the code. The top icon renders correctly:
info#site.org <i class="fas fa-envelope" style="margin-left: 5px"></i><br />
#site <i class="fab fa-twitter" style="margin-left: 5px"></i><br />
site <i class="fa fa-facebook" style="margin-left: 5px"></i>
Any suggestions on how to get the social icons working is greatly appreciated!
Fix: This was just a case of not having updated FontAwesome to the latest version, so the icon references were broken. Easy mistake! Hopefully this helps someone.
Icons work properly. Probably you made an error somewhere.
<i class="fab fa-3x fa-facebook"></i>
<i class="fab fa-3x fa-facebook-f"></i>
<i class="fab fa-3x fa-facebook-square"></i>
<i class="fab fa-3x fa-twitter"></i>
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.2/js/all.min.js"></script>

Font Awesome icon size not increasing

I have Font Awesome icons installed on this site. The icons size isn't increasing even after adding the class to increase size.
<ul class="stay-connected-inner list-inline">
<li><i class="fa fa-twitter fa-3" aria-hidden="true"></i></li>
<li><i class="fa fa-linkedin fa-3" aria-hidden="true"></i></li>
<li><i class="fa fa-medium fa-3" aria-hidden="true"></i></li>
<li><i class="fa fa-linkedin fa-3" aria-hidden="true"></i></li>
</ul>
To increase icon sizes relative to their container, use the fa-lg (33% increase), fa-2x, fa-3x, fa-4x, or fa-5x classes.
<ul class="stay-connected-inner list-inline">
<li><i class="fa fa-twitter fa-3x" aria-hidden="true"></i></li>
<li><i class="fa fa-linkedin fa-3x" aria-hidden="true"></i></li>
<li><i class="fa fa-medium fa-3x" aria-hidden="true"></i></li>
<li><i class="fa fa-linkedin fa-3x" aria-hidden="true"></i></li>
</ul>
font-awesome icons are texts. So use font-size to increase the size of font-awesome icons.
For eg.,
i {
font-size: 18px;
}
For font awesome icons sizing please check this link.
http://fontawesome.io/examples/
To increase icon sizes relative to their container, use the fa-lg (33% increase), fa-2x, fa-3x, fa-4x, or fa-5x classes.
<i class="fa fa-camera-retro fa-lg"></i> fa-lg
<i class="fa fa-camera-retro fa-2x"></i> fa-2x
<i class="fa fa-camera-retro fa-3x"></i> fa-3x
<i class="fa fa-camera-retro fa-4x"></i> fa-4x
<i class="fa fa-camera-retro fa-5x"></i> fa-5x
I had the same problem. For some reason the fa class is overriding the fa-2x class on the awesome font library. I found a blog that they knew it was an issue back in 2014 but haven't addressed it yet. On my site I added the style class again and added !important which fixed my problem.
<style>
.fa-2x{
font-size:2em !important;
};
</style>
use following inline css
<style type="text/css">
.fa-3{
font-size: 30px;
}
</style>
if you are using font awesome or font awesome pro icons in Angular 5+ using svg with Javascript. The easy way to increase your custom font size is:
.svg-inline--fa{
font-size:1.500em; //use your custom font size. If you do not want to apply the font awesome size classes
}
Apply this in your custom component to see the changes immediately.
In my case setting fa fa-5x, or font-size or height didn't help, but:
width: 20px !important; // 20px is an example value
Also be cautious if you have padding applied!

FontAwesome Stack Replace on Hover

So I've been trying to do a quick animation that replaces an entire span on hover but I can't seem to get it to work. How should I approach going about replacing a span on hover?
<h1>I need this replaced...</h1>
<span class="fa-stack fa-lg">
<i class="fa fa-square-o fa-stack-2x"></i>
<i class="fa fa-twitter fa-stack-1x"></i>
</span>
<h1>to this</h1>
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-flag fa-stack-1x fa-inverse"></i>
</span>
<h1>on hover</h1>
Sample CodePen here.
By changing the :before css properties for the twitter on hover you can achieve the output.
span.fa-stack:hover i.fa-twitter:before{content:"\f024"; color:#fff}
span.fa-stack:hover i.fa-square-o:before{content:"\f111"}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<h1>I need this replaced...</h1>
<span class="fa-stack fa-lg">
<i class="fa fa-square-o fa-stack-2x"></i>
<i class="fa fa-twitter fa-stack-1x"></i>
</span>
You can achieve this in CSS by combining the :hover and :first-child/:last-child CSS selectors.
.fa-stack.fa-lg:hover :first-child:before {
content: "\f111";
}
.fa-stack.fa-lg:hover :last-child:before {
content: "\f024";
color: #fff;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<span class="fa-stack fa-lg">
<i class="fa fa-square-o fa-stack-2x"></i>
<i class="fa fa-twitter fa-stack-1x"></i>
</span>

Spacing between Font Awesome icons

How can I set spacing between icons that appear in line? Here's my code:
<p>
<i class="fa fa-facebook fa-2x"></i>
<i class="fa fa-twitter fa-2x"></i>
<i class="fa fa-google-plus fa-2x"></i>
</p>
The icons are too close to each other for now.
use the fa-fw class:
http://fortawesome.github.io/Font-Awesome/examples/
It's clean, and better than adding a style to your elements.
Just set a margin as you would do for anything else. Pure CSS.
Actually you can use to create a space
<i class="fa fa-home fa-fw"></i> <i class="fa fa-home fa-fw"></i>
Other answers mention the fa-fw class, which works well for a lot of scenarios. However, there are some cases where this is not enough spacing.
For those who use Bootstrap, use me- (margin-right) or ms- (margin-left) classes to specify which side and how much margin.
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
<!-- Fontsawesome CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"
integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w=="
crossorigin="anonymous" />
<title>Bootstrap 5.0 Fontsawesome Margin Example</title>
</head>
<body>
<h1>No Margin</h1>
<p>
<i class="fab fa-facebook"></i>
<i class="fab fa-twitter"></i>
<i class="fab fa-google-plus"></i>
</p>
<h1>ME-1</h1>
<p>
<i class="fab fa-facebook me-1"></i>
<i class="fab fa-twitter me-1"></i>
<i class="fab fa-google-plus me-1"></i>
</p>
<h1>ME-2</h1>
<p>
<i class="fab fa-facebook me-2"></i>
<i class="fab fa-twitter me-2"></i>
<i class="fab fa-google-plus me-2"></i>
</p>
<h1>ME-3</h1>
<p>
<i class="fab fa-facebook me-3"></i>
<i class="fab fa-twitter me-3"></i>
<i class="fab fa-google-plus me-3"></i>
</p>
<h1>ME-4</h1>
<p>
<i class="fab fa-facebook me-4"></i>
<i class="fab fa-twitter me-4"></i>
<i class="fab fa-google-plus me-4"></i>
</p>
<h1>ME-5</h1>
<p>
<i class="fab fa-facebook me-5"></i>
<i class="fab fa-twitter me-5"></i>
<i class="fab fa-google-plus me-5"></i>
</p>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta3/dist/js/bootstrap.min.js"
integrity="sha384-j0CNLUeiqtyaRmlzUHCPZ+Gy5fQu0dQ6eZ/xAww941Ai1SxSY+0EQqNXNE6DZiVc"
crossorigin="anonymous"></script>
</body>
</html>
https://getbootstrap.com/docs/5.0/utilities/spacing/#margin-and-padding