Font Awesome Hover Issue - css

This question is related to https://stackoverflow.com/questions/25770590/change-color-when-hover-a-font-awesome-icon#=
What I'm trying to achieve is the hover style on Circle behind icon.
<span class="fa-stack fa-5x">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-flag fa-stack-1x fa-inverse"></i>
</span>
.fa-circle:hover {
color: red;
}
http://jsfiddle.net/uvamhedx/802/
As you can see, when you go over the image, only one part of it will activate the hover effect. I guess this is because other image (flag) is on top if it.. Is there any way I could "avoid" flag icon and make it work?

.fa-circle is a child of .fa-stack, so check for the hover on the parent.
If you only want to target .fa-circle:
.fa-stack:hover .fa-circle{
color: red;
}
If you want to target all .fa-stacks:
.fa-stack:hover{
color: red;
}
Or if you create your own class, it won't affect the normal behaviour:
<span class="fa-stack fa-5x hover-change">
CSS:
.hover-change:hover {
color: red;
}

I use custom classes to avoid default behavior of original definitions:
HTML :
<span class="fa-stack fa-5x customClass">
<i class="fa fa-circle fa-stack-2x customClassRed"></i>
<i class="fa fa-flag fa-stack-1x fa-inverse"></i>
</span>
CSS :
.customClass:hover .customClassRed {
color: red;
}

Related

Double circle stack using font awesome

Is there an easy way to make a double circle around a number with the font awesome circle-thin icon? I also want to be able to maybe change to using the square-o icon instead.
Here is a Plunker example but this is only perfect at certain resolutions and I also want the lines to be same width: https://plnkr.co/edit/M9Dku94gApyxQ8zBzrVw?p=preview
.double {
top: -4.3px;
left: -1.9px;
font-size: 2.6em;
}
<span class="fa-stack fa-1x">
<i class="fa fa-circle-thin fa-stack-2x double"></i>
<i class="fa fa-circle-thin fa-stack-2x"></i>
<strong class="fa-stack-1x">4</strong>
</span>
you can try scale, since px is not very good
.double { transform: scale(1.3); }
<style>
.double {
top: -0.0px;
left: -0.0px;
font-size: 1.4em;
}
</style>
<body>
<span class="fa-stack fa-2x">
<i class="fa fa-circle-o fa-stack-1x double"></i>
<i class="fa fa-circle-thin fa-stack-2x "></i>
<strong class="fa-stack-1x">4</strong>
</span>
you could use fa-cicle-o and circle-thin
edit:
looks better now with style added

Font Awesome Icons in CSS - Larger Sizes

I am using this in my CSS:
#ribbon h2:before {
content: '\f145';
font-family: 'FontAwesome';
color: #FFF;
}
I'd like the icon to be larger using what's here:
http://fontawesome.io/examples/
<i class="fa fa-ticket fa-lg"></i> fa-lg
<i class="fa fa-ticket fa-2x"></i> fa-2x
<i class="fa fa-ticket fa-3x"></i> fa-3x
<i class="fa fa-ticket fa-4x"></i> fa-4x
<i class="fa fa-ticket fa-5x"></i> fa-5x
But I cannot figure out how to mix these codes so I can make the icon larger since one uses numbers and one uses text code. What should my CSS look like if I want to use fa-2x for example?
Thank you!
I'm not exactly sure what you mean but you can increase the icon sizes by increasing the font-size.
You can also create your own classes with various font sizes and assign them to change the icon sizes.
Example:
HTML:
<i class="fa fa-ticket fa-6x"></i>
CSS:
.fa-6x
{
font-size: 6em; /* x6 larger icon */
}
Hope this helps.

Change FontAwesome icon size in primefaces (p:commandButton and p:menuitem)

I'm trying out the FontAwesome icon inside p:commandButton and p:menuitem.
I'm able to display the icons, however compared to the built-in mobile icons, the FontAwesome icons seem too small. It looks inconsistent if you have other PF components using themeroller icons.
Is there a way to increase size of the FontAwesome icons?
and I have also try in style to increase font-size and fa-lg, fa-2x, fa-3x, fa-4x, or fa-5x classes but doesn't work.
<p:commandButton icon="ui-icon-mobile-phone" id="sendSMSBtn"
styleClass="btn btn-info btn-lg" onclick="modalDialog.show()"
oncomplete="modalDialog.hide();"
action="#{myBean.getMobileNo()}"
update=":frm:messages" style="font-size:30px">
Generated HTML :
<button type="submit" title="Send Bulk SMS" onclick="modalDialog.show();PrimeFaces.ab({source:'frm:dataTable:sendSMSBtn',update:'frmMassSMS frm:messages',oncomplete:function(xhr,status,args){modalDialog.hide();;}});return false;" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only btn btn-info btn-lg fa-fw" name="frm:dataTable:sendSMSBtn" id="frm:dataTable:sendSMSBtn" role="button" aria-disabled="false"><span class="ui-button-icon-left ui-icon ui-c ui-icon-mobile-phone"></span><span class="ui-button-text ui-c">ui-button</span></button>
You can use fa-2x, fa-3x,... only if not use value component into <p:commandButton>. Just put into styleClass whatever you want to describe this button.
<p:commandButton styleClass="fa fa-pencil fa-2x btn btn-lg btn-success someclass" process="staffTable" update=":MStaffUpdateForm:staffUpdate" oncomplete="PF('staffUpdateDialog').show()" />
Then, your XHTML generate code:
<span class="ui-button-text ui-c">ui-button</span>
image:
Then, just make up your javascript like that:
<script>
$(function() {
$('.someclass').text("");
}
</script>
Result with normal-size:
Result with fa-2x:
Overriding width and font-size properties of "ui-icon" CSS works for me:
.button {
width: 100px;
height: 50px;
}
.ui-icon {
width: 24px !important;
font-size: 24px !important;
}
Example button:
<p:commandButton image="fa fa-download" value="Test" styleClass="button"/>
Yes you can!
But if you want use the FA you should add a reference of library. I had the same problem and I did that:
<!-- CSS With Font-Awesome.jar -->
<link href="/webjars/font-awesome/4.6.3/css/font-awesome.css" rel="stylesheet" type="text/css" media="screen"/>
Some code:
<td >
<i class="fa fa-camera-retro"></i> fa-camera-retro
<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
</td>
You should add too at web.xml that fragment:
<context-param>
<param-name>primefaces.FONT_AWESOME</param-name>
<param-value>true</param-value>
</context-param>
Good luck!

Need help in stacking font-awesome icons

I recently upgraded the font-awesome version from 3.2.1 to 4.
I had this working in 3.2.1
<li><span class="icon-stack stacked"><i class="icon-circle icon-stack-base"></i><i class="icon-phone icon-2x icon-light">
</i></span><span class="stacktext">Your Phone Number</span></li>
.stacked
{
float: left;
margin-right: 15px;
color: #3ECCFC;
}
.stacktext
{
text-align:left;
font-size: 14px;
color: #444444;
}
But it is not stacking up well in version 4.
<li><span class="fa fa-stack stacked"><i class="fa fa-circle fa fa-stack-base"></i><i class="fa fa-phone icon-2x fa fa-light">
</i></span><span class="stacktext">Your Phone Number</span></li>
You only have to use the class fa once in a class="". I've updated several bits in your code.
Define the main stack size in the <span> around the <i> elements. stacked is obsolete in Font Awesome 4, since fa-stack defines a stack too. Also fa-light is changed to fa-inverse. At last fa-stack-1x and fa-stack-2x are used to scale the icons in the stack. fa-stack-2x will be used to make an icon larger compared to the other icon in the stack.
Everything put together results in:
<li>
<span class="fa-stack fa-2x">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-phone fa-stack-1x fa-inverse"></i>
</span>
<span class="stacktext">Your Phone Number</span>
</li>
Please check the examples of stacks given on the Font Awesome website: Stacks.
The icon- class prefix become fa fa- :
icon-* -> fa fa-*
Source: https://github.com/FortAwesome/Font-Awesome/wiki/Upgrading-from-3.2.1-to-4

How to style icon color, size, and shadow of FontAwesome Icons

How could I style the color, size and shadow of icons from FontAwesome's Icons?
For example, FontAwesome's site will show some icons in white and some in red but won't show the CSS for how to style them that way ...
Given that they're simply fonts, then you should be able to style them as fonts:
#elementID {
color: #fff;
text-shadow: 1px 1px 1px #ccc;
font-size: 1.5em;
}
You can also just add style inline:
<i class="icon-ok-sign" style="color:green"></i>
<i class="icon-warning-sign" style="color:red"></i>
If you are using Bootstrap at the same time, you can use:
<i class="fa fa-check-circle-o fa-5x text-success" ></i>
Otherwise:
<i class="fa fa-check-circle-o fa-5x" style="color:green"></i>
Looks like the FontAwesome icon color responds to text-info, text-error, etc.
<div style="font-size: 44px;">
<i class="icon-umbrella icon-large text-error"></i>
</div>
inyour.css file:
*.icon-white {color: white}
*.icon-silver {color: silver}
inyour.html file:
<a><i class="icon-book icon-white"></i> Book</a>
<a><i class="icon-ok-sign icon-silver"></i> OK</a>
For Size: fa-lg, fa-2x, fa-3x, fa-4x, fa-5x
For Color: <i class="fa fa-link fa-lg" aria-hidden="true"style="color:indianred"></i>
For Shadow: .fa-linkedin-square{text-shadow: 3px 6px #272634;}
There is a really simple way to change the colour of Font Awesome icons.
<!-- Font Awesome insert code -->
<script src="https://use.fontawesome.com/49b98aaeb5.js"></script>
<!-- End -->
<i class="fa fa-thumbs-up fa-5x" aria-hidden="true" style="color:#00cc6a"></i>
<i class="fa fa-thumbs-up fa-4x" aria-hidden="true" style="color:#00cc6a"></i>
<i class="fa fa-thumbs-up fa-3x" aria-hidden="true" style="color:#00cc6a"></i>
<i class="fa fa-thumbs-up fa-2x" aria-hidden="true" style="color:#00cc6a"></i>
<i class="fa fa-thumbs-up" aria-hidden="true" style="color:#00cc6a"></i>
You can change the hex code to your preference.
NOTE: The text colour will change the icon colour as well unless there is a style="color:#00cc6a" within the i tag.
Using FA 4.4.0 adding
.text-danger
color: #d9534f
to the document css and then using
<i class="fa fa-ban text-danger"></i>
changes the color to red. You can set your own for any color.
http://fortawesome.github.io/Font-Awesome/examples/
<i class="icon-thumbs-up icon-3x main-color"></i>
Here I have defined a global style in my CSS where main-color is a class, in my case it is a light blue hue. I find that using inline styles on Icons with Font Awesome works well, esp in the case when you name your colors semantically, i.e. nav-color if you want a separate color for that, etc.
In this example on their website, and how I have written in my example as well, the newest version of Font Awesome has changed the syntax slightly of adjusting the size.Before it used to be:
icon-xxlarge
where now I have to use:
icon-3x
Of course, this all depends on what version of Font Awesome you have installed on your environment. Hope this helps.
Just target font-awesome predefined class name
in ex:
HTML
<i class="fa fa-facebook"></i>
CSS
i.fa {
color: red;
font-size: 30px;
}
In FontAwesome 4.0, the classes change to 'fa-2x', 'fa-3x'.
Simply you can define a class in your css file and cascade it into html file like
<i class="fa fa-plus fa-lg green"></i>
now write down in css
.green{ color:green}
Please refer to the link
http://www.w3schools.com/icons/fontawesome_icons_intro.asp
<i class="fa fa-car"></i>
<i class="fa fa-car" style="font-size:48px;"></i>
<i class="fa fa-car" style="font-size:60px;color:red;"></i>
<i class="fa fa-car fa-lg"></i>
<i class="fa fa-car fa-2x"></i>
<i class="fa fa-car fa-3x"></i>
<i class="fa fa-car fa-4x"></i>
<i class="fa fa-car fa-5x"></i>
I had the same problem when I tried to use the icons directly from BootstrapCDN (the easiest way). Then I downloaded the CSS file and copied it to my site's CSS folder the CSS file (Described under the 'easy way' in font awesome documentation), and everything started working as they should.
Credit: Can I change the color of Font Awesome's icon color?
(this answer builds on that answer)
(for the bookmark icon, for example:)
inyour.css file:
.icon-bookmark.icon-white {
color: white;
}
inyour.html file:
<div class="icon-bookmark icon-white"></div>
Wrap the i tag in p or span, then you can use bootstrap css class
<p class="text-success"><i class="fa fa-check"></i></p>
For Font Awesome 5 SVG version, use
filter: drop-shadow(0 0 3px rgba(0,0,0,0.7));
As it has been pointed out, font awesome icons are text, consequently you style it using the appropriate CSS attributes. For example:
.fa-twitter-square {
font-size: 15px;
color: red;
}
If, as it happens quite a bit to me, the icon size doesn't change at all, add "!important" to the font-size attribute.
.fa-twitter-square {
font-size: 15px !important;
color: red;
}
For Sizing Icons
Both our Web Fonts + CSS and SVG + JS frameworks include some basic controls for sizing icons in the context of your page’s UI.
you can use like
<i class="fas fa-camera fa-xs"></i>
<i class="fas fa-camera fa-sm"></i>
<i class="fas fa-camera fa-lg"></i>
<i class="fas fa-camera fa-2x"></i>
<i class="fas fa-camera fa-3x"></i>
<i class="fas fa-camera fa-5x"></i>
<i class="fas fa-camera fa-7x"></i>
<i class="fas fa-camera fa-10x"></i>
https://fontawesome.com/how-to-use/on-the-web/styling/sizing-icons
Dynamically change the css properties of .fa-xxx icons:
<li class="nws">
<a href="#NewsModal" class="urgent" title="' + title + '" onclick=""><span class="label label-icon label-danger"><i class="fa fa-bolt"></i></span>'
</a>
</li>
<script>
$(document).ready(function(){
$('li.nws').on("focusin", function(){
$('.fa-bolt').addClass('lightning');
});
});
</script>
<style>
.lightning{ /*do something cool like shutter*/}
</style>
text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
Try to simply use something like fa-lg,fa-2x,fa-3x,fa-4x,fa-5x to increase the icon size relative to their container
for eg:-
I would not advice you to use built in font-awesome styling like the fa-5x etc; for fear they may change it and you would have to keep chainging your application code to meet up with the latest standard. You simply avoid this by giving each font-awesome class you want to style uniformly the same class say:
<i class="fa fa-facebook-square fa-sabi-social-icons" aria-hidden="true"></i>
<i class="fa fa-twitter-square fa-sabi-social-icons" aria-hidden="true"></i>
<i class="fa fa-google-plus-square fa-sabi-social-icons" aria-hidden="true"></i>
Here the class is fa-sabi-social-icons
Then in your css you can the style the fonts using the same css rules you would style a normal font with.
e.g
.fa-sabi-social-icons {
color: //your color;
font-size: // your font-size in px, em or %;
text-shadow: 2px 2px #FF0000;
}
That should get your font-awesome fonts styled
Here is an example how to styling font-awesome:
.arrow i.fa {
color: white !important;
font-size: 2.2rem;
opacity: .3;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="arrow d-none d-md-block">
<i class="fa fa-angle-down"></i>
</div>
That's it.

Resources