Font awesome icons misaligned on converting into directives - css

Icons are misaligned if I use directive and working fine if I used plain html code..
Method 1) font awesome icons using directives (icons are horizontally misaligned):
js:
app.directive("roIcon", function() {
return {
restrict: "E",
templateUrl: "templates/roIcon.html",
scope: {
type: "#"
}
};
});
"roIcon.html" template:
<span ng-if="type === 'add'">
<i class="fa fa-plus"></i>
</span>
<span class="fa-stack fa-lg stacked-icons" ng-if="type === 'export-file'">
<i class="fa fa-file-o fa-stack-2x"></i>
<span class="fa-stack stack-bg">
<i class="fa fa-arrow-right fa-small fa-stack-1x"></i>
</span>
</span>
<span class="fa-stack fa-lg stacked-fork" ng-hide="isTile == true" ng-if="type === 'start-workflow'">
<i class="fa fa-code-fork fa-rotate-90 fa-stack-2x"></i>
<span class="fa-stack stack-bg">
<i class="fa fa-plus fa-small fa-stack-1x"></i>
</span>
</span>
Icons directive included in html:
<ro-icon type="add"></ro-icon>
<ro-icon type="export-file"></ro-icon>
<ro-icon type="start-workflow"></ro-icon>
Method 2) Direct inclusion of icons into html file is working fine:
<span>
<i class="fa fa-plus"></i>
</span>
<span class="fa-stack fa-lg stacked-icons" title="export file">
<i class="fa fa-file-o fa-stack-2x"></i>
<span class="fa-stack stack-bg">
<i class="fa fa-arrow-right fa-small fa-stack-1x"></i>
</span>
</span>
<span class="fa-stack fa-lg stacked-fork">
<i class="fa fa-code-fork fa-rotate-90 fa-stack-2x"></i>
<span class="fa-stack stack-bg">
<i class="fa fa-plus fa-small fa-stack-1x"></i>
</span>
</span>
The only difference I can see in both the view source is the icons rendered with directives contains a wrapper non-html tag ...., the rest of the html is same.
I am not able to find out whether this non-html tag is making any difference in alignment as shown in figure?
Appreciate your help..

Related

Stack two FontAwesome icons

I need to group 2 icons like . I've tried to use fa-stack class but it overlaps the images and I don't know how to put one above another.
<span class="fa-stack fa-lg">
<i class="fa fa-envelope fa-stack-1x"></i>
<i class="fa fa-ellipsis-h fa-stack-2x"></i>
</span>
If you are using same structure, you can move the second icon little up using css negative margin.
<span class="fa-stack fa-lg">
<i class="fa fa-envelope fa-stack-1x"></i>
<i class="fa fa-ellipsis-h fa-stack-2x"></i>
</span>
span i:not(:first-child){
margin-top:-15px;
}
Here is an example

bootstrap accordion in color

I know this sound crazy or easy but I'm not getting any result.
I'm working on bootstrap accordion and I'm trying to figure out how to write in CSS to allow show ALL color Blue in (icon, text and background color) in at the SAME TIME using CSS :focus when person clicked the link or accordion...
please see one line of accordion of codes...
<i class="fa fa-user" aria-hidden="true"></i> Members
or please see the whole sample of each accordion buttons...
<div id="sidebar-wrapper">
<ul class="sidebar-nav">
<dl class="accordion">
<dt><span><i class="fa fa-tachometer" aria-hidden="true"></i> Manage</span><i class="accordion_icon fa fa-chevron-up"></i></dt>
<dd class="accordion_content">
<div class="list-group">
<i class="fa fa-tachometer blue" aria-hidden="true"></i> Dashboard
<i class="fa fa-users" aria-hidden="true"></i> Members
<i class="fa fa-clipboard" aria-hidden="true"></i> Posts
<i class="fa fa-tachometer" aria-hidden="true"></i> Vestibulum at eros
</div>
</dd>
<dt><span><i class="fa fa-tachometer" aria-hidden="true"></i> Settings</span><i class="accordion_icon fa fa-chevron-up"></i></dt>
<dd class="accordion_content">
<div class="list-group">
<i class="fa fa-user" aria-hidden="true"></i> Members
<i class="fa fa-clipboard" aria-hidden="true"></i> Posts
<i class="fa fa-comments" aria-hidden="true"></i> comments
<i class="fa fa-user-secret" aria-hidden="true"></i> Privacy
<i class="fa fa-bell" aria-hidden="true"></i> Notifications
<i class="fa fa-envelope" aria-hidden="true"></i> Emails
<i class="fa fa-globe" aria-hidden="true"></i> Sites Infor
</div>
</dd>

Font Awesome: Stacked and Fixed Width

How can I have stacked icons and apply fixed width to both icons (or to the stack itself)?
<div class="col-md-4">
<p>
<span class="fa-stack text-danger">
<i class="fa fa-fw fa-stack-2x fa-stop"></i>
<i class="fa fa-fw fa-stack-1x fa-exclamation fa-inverse"></i>
</span> Some text
</p>
</div>
The above example does not result in a fixed width icon. Adding fa-fw to the span class does not resolve the issue. Thoughts?
Seems that a newer version of Font Awesome fixes this issue. I am using v4.4 below.
<div class="col-md-4">
<div class="list-group">
<a class="list-group-item" href="#">
<span class="fa-stack text-danger">
<i class="fa fa-fw fa-stack-2x fa-stop"></i>
<i class="fa fa-fw fa-stack-1x fa-exclamation fa-inverse"></i>
</span> Some text
</a>
<a class="list-group-item" href="#">
<span class="fa-stack">
<i class="fa fa-fw fa-stack-2x"></i>
<i class="fa fa-fw fa-stack-1x fa-anchor"></i>
</span> Anchor
</a>
</div>
</div>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet" />
<div class="col-md-4">
<div class="list-group">
<a class="list-group-item" href="#">
<span class="fa-stack text-danger">
<i class="fa fa-fw fa-stack-2x fa-stop"></i>
<i class="fa fa-fw fa-stack-1x fa-exclamation fa-inverse"></i>
</span> Some text
</a>
<br>
<a class="list-group-item" href="#">
<span class="fa-stack">
<i class="fa fa-fw fa-stack-2x"></i>
<i class="fa fa-fw fa-stack-1x fa-anchor"></i>
</span> Anchor
</a>
</div>
</div>
In order for the rest of the icons in the list-group to appear with the same fixed width they have to be stacked behind an empty icon.
I did not test it but what if you try :
<div class="col-md-4">
<p>
<span class="fa-stack text-danger">
<i class="fa fa-fw fa-stack-2x fa-stop" style="font-size:20px"></i>
<i class="fa fa-fw fa-stack-1x fa-exclamation fa-inverse" style="font-size:20px"></i>
</span> Some text
</p>
</div>
... and adjust the values to fit the width attempted.
If it works, you could overwrite the original styles .fa-stop, .fa-exclamation ... directly in your CSS stylesheet. Maybe you will have to use !important hack.

Font-Awesome in WordPress - Icons not stacking correctly

I am using Font-Awesome in a WordPress site have included the Font-Awesome CDN in my functions.php file according to this bit of php.
I can insert the icons into my site but am unable to get icons to stack according to this example code:
<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>
fa-twitter on fa-square-o
You can see the output of this code here.
Does anyone have any thoughts on why this may not be working? I'm pretty sure that there are no CSS class clashes...
Doing view source on your page:
<span class="fa-stack fa-lg"><br />
<i class="fa fa-square-o fa-stack-2x"></i><br />
<i class="fa fa-twitter fa-stack-1x"></i><br />
</span>
The <br /> elements are breaking Font Awesome's CSS. I imagine WordPress is putting those in automatically for you, so try putting everything on one line so WordPress doesn't try to add any <br /> elements into the code:
<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>

How can I overlay a number on top of a FontAwesome glyph?

How can I overlay a number between 0 and 99 in the middle of 'icon-star-empty'?
Simply do this from the Font Awesome docs on Stacked Icons:
<span class="fa-stack fa-lg">
<i class="fa fa-star-o fa-stack-2x"></i>
<i class="fa fa-stack-1x">1</i>
</span>
Here is what I use for counter overlays (badges) with FontAwesome (FA) 5.1. Unlike using the new fa-layers method, this does not require SVG+JS. Simply add a data-count attribute to <i> markup...
CSS
.fas[data-count]{
position:relative;
}
.fas[data-count]:after{
position: absolute;
right: -0.75em;
top: -.75em;
content: attr(data-count);
padding: .5em;
border-radius: 10em;
line-height: .9em;
color: white;
background: rgba(255,0,0,.75);
text-align: center;
min-width: 2em;
font: bold .4em sans-serif;
}
Markup
<i class="fas fa-envelope" data-count="8"></i>
<i class="fas fa-address-book fa-lg" data-count="16"></i>
<i class="fas fa-bookmark fa-2x" data-count="4"></i>
<i class="fas fa-angry fa-3x" data-count="32"></i>
<i class="fas fa-bell fa-4x" data-count="2"></i>
Example
Conclusion
Some FA icon sizes may require badge size/position tweaking, but works well for my purposes. All colors/positions can be adjusted for calendar overlays, text labels, or OP's star outline.
Note
Untested, but using the same CSS should work with older FA versions by changing fas class to fa instead.
This can also be done using Font Awesome Layers using version 5.0
<div class="fa-4x">
<span class="fa-layers fa-fw" style="background:MistyRose">
<i class="fas fa-circle" style="color:Tomato"></i>
<i class="fa-inverse fas fa-times" data-fa-transform="shrink-6"></i>
</span>
<span class="fa-layers fa-fw" style="background:MistyRose">
<i class="fas fa-bookmark"></i>
<i class="fa-inverse fas fa-heart" data-fa-transform="shrink-10 up-2" style="color:Tomato"></i>
</span>
<span class="fa-layers fa-fw" style="background:MistyRose">
<i class="fas fa-play" data-fa-transform="rotate--90 grow-2"></i>
<i class="fas fa-sun fa-inverse" data-fa-transform="shrink-10 up-2"></i>
<i class="fas fa-moon fa-inverse" data-fa-transform="shrink-11 down-4.2 left-4"></i>
<i class="fas fa-star fa-inverse" data-fa-transform="shrink-11 down-4.2 right-4"></i>
</span>
<span class="fa-layers fa-fw" style="background:MistyRose">
<i class="fas fa-calendar"></i>
<span class="fa-layers-text fa-inverse" data-fa-transform="shrink-8 down-3" style="font-weight:900">27</span>
</span>
<span class="fa-layers fa-fw" style="background:MistyRose">
<i class="fas fa-certificate"></i>
<span class="fa-layers-text fa-inverse" data-fa-transform="shrink-11.5 rotate--30" style="font-weight:900">NEW</span>
</span>
<span class="fa-layers fa-fw" style="background:MistyRose">
<i class="fas fa-envelope"></i>
<span class="fa-layers-counter" style="background:Tomato">1,419</span>
</span>
</div>
You css should look something like:
.contain-i-e-s,.icon-empty-star,.text-i-e-s{
height:100px; width:100px;
}
.contain-i-e-s{
position:relative;
}
.text-i-e-s{
text-align:center; position:absolute;
}
Your HTML might look like:
<div class='contain-i-e-s'>
<i class='icon-empty-star'></i>
<div class='text-i-e-s'>99</div>
</div>

Resources