How to change the direction of a font awesome icon? - javascript

I am using the font-awsome library to show a unlock icon .
So, By default the direction is in right direction, I want to change that to the left.
<i class="fas fa-unlock-alt"></i>
SO, is there any way through which I can change the direction of the unlock icon ?

You can use the fa-flip-horizontal class as documented here.
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.min.css" rel="stylesheet"/>
<i class="fas fa-unlock-alt"></i>
<i class="fas fa-unlock-alt fa-flip-horizontal"></i>

You can rotate and flip icons with font awesome. In your case you can try this:
<i class="fas fa-unlock-alt fa-flip-horizontal"></i>
Check out this link for more information https://fontawesome.com/how-to-use/on-the-web/styling/rotating-icons

Considering the JS+SVG version you can use flip-h to flip the icon horizontally
<script defer src="https://use.fontawesome.com/releases/v5.8.1/js/all.js"></script>
<i class="fas fa-unlock-alt" data-fa-transform="flip-h"></i>
More details: https://fontawesome.com/how-to-use/on-the-web/styling/power-transforms

Related

Redirect to another page and scroll to specific <div> are not working together

Ok, this is my very first question posted to this forum so please be kind.. :)
I'm using ASP.NET MVC 5 and I am trying to do a two step process when an icon is clicked.
Select the correct page
Scroll down to a certain section on that page.
Here is what I got so far:
<a class="sidebar-brand d-flex align-items-center justify-content-start" >
<div class="notification-bell" style="color:red">
<i class="fas fa-fw fa-bell fa-2x" title="Number of Unread Comments" alert-count=#ViewBag.TotalUnreadComments.ToString() onclick='scrollToElement("CommentSection");'></i>
</div>
</a>
And the Javascript
<script type='text/javascript'>
function scrollToElement(id) {
// Set correct page
window.location.replace("/TodoListDashboard");
//Get target
var target = document.getElementById(id).offsetTop;
//Scrolls to that target location
window.scrollTo(0, target);
}
</script>
The funny thing is that either of these actions work by themselves but they won't work together.
Any ideas would be greatly appreciated!!!
Ok, I feel kind of foolish but I figured out an easy fix...
For this problem, I just created a javascript function and added both items together like this:
<script type='text/javascript'>
function scrollToComments() {
window.location.replace("/TodoListDashboard#CommentSection");
}
</script>
Then I just changed my onclick call to:
<i class="fas fa-fw fa-bell fa-2x" title="Number of Unread Comments" alert-count=#ViewBag.TotalUnreadComments.ToString() onclick='scrollToComments();'></i>

How to attach NGBootstrap tooltip to font awesome icon

Trying to add a tooltip to a font awesome icon in an Angular page. The normal Bootstrap method seems to be ignored so I am trying to use the NGBootstrap method used for adding a tooltip to buttons, but the tool tip never displays. https://ng-bootstrap.github.io/#/components/tooltip/examples
The typical Bootstrap method causes an error of Cannot set property 'title' of undefined when hovering.
<i class="fa fa-info-circle" data-toggle="tooltip" title="Name here"></i>
In the component:
ngafterviewinit() {
$(function() {
$('[data-toggle="tooltip"]').tooltip();
}
};
You can also try using button tag.
<div class="infoCSSClass">
<button class="icon-info" data-container="body" ngbTooltip="Here is tooltip text" #toolTip="ngbTooltip" (click)="toolTip.open()" placement="top"></button>
</div>
This seems to work:
<i id="icon" class="fa fa-1x fa-info-circle" [ngClass]="icon" aria-hidden="true" placement="right" ngbTooltip="tipContent"></i>

How can I animate an ionic icon

I am trying to make this icon move but so far had no luck doing this. Does anyone know how I can make this icon flicker or something?
<i id="informationCommentIcon" class="icon ion-fireball assertive "></i>
<a id="informationCommentText" ng-click="promoFunction()">Promo Deal</a>

Never show two divs at the same time

I'm working on a project where ng-cloak is unavailable due to the way the css files are loaded, so I'm looking for a less worse solution and have tried a few different things.
I never want to show these two icons at the same time. The problem is, the bottom one (angle right) shows up briefly since the promise for the data source is still resolving. How can I make sure these two icons will never show up at once?
<i class=" fa invalid-data-icon fa-angle-down" ng-hide="vm.hideInvalid"
ng-show="vm.data.datasources.length">
</i>
<i class="fa invalid-data-icon fa-angle-right" ng-show="vm.hideInvalid"
ng-hide="vm.data.datasources.length">
</i>
EDIT:
went with this from the accepted answer:
<i class=" fa invalid-data-icon fa-angle-down" ng-class="{'rotate-icon':vm.data.datasources[1].length==0 || vm.hideInvalid}"></i>
First using but ng-show and ng-hide in the same tag is a pretty bad idea.
You should do something like :
<i class=" fa invalid-data-icon fa-angle-down"
ng-show="vm.hideInvalid==false && vm.data.datasources.length==0">
</i>
<i class="fa invalid-data-icon fa-angle-right"
ng-show="vm.hideInvalid==true && vm.data.datasources.length==0">
</i>
Considering that as long your promise is not resvoled you would have initialize hideInvalid and datasources to undefined.
Alternative approach: Only use one icon in your code, and rotate it with a css class:
<i class=" fa invalid-data-icon fa-angle-down" ng-class={'rotate-icon':!!vm.data.datasources.length}></i>
(my Angular skills are a bit rusty, but you get the jist...)
Then in your CSS, something like this:
.rotate-icon {
transform: rotate(-90deg)
}

i want to change the element image with text in html/stylesheet

am using this code to make hidden dropdown list but instead of that magnifier icon at topright corner, i want to replace it with text "search" or somethinf else, how can i do that? i am a newbie, please excuse me.
link of files https://drive.google.com/folderview?id=0B7cm2DCx8TxvflJKUy1KNU5fbmo1eDJCVU1mQW1FdEtVOE9FbDEzZlM4LVNXSkhVOUlfSUk&usp=sharing
Now you'r loading an icon so change this:
<li><i class="fa fa-search fa-lg"></i></li>
To this:
<li>Search</li>
https://jsfiddle.net/razitazi/3r18zngb/

Categories

Resources