How to make a new Icon in css? - css

I'm not sure whether the title is correct But I have a custom png file that I want to apply as an icon in an existing application. Because this is an existing application, I can't make too many changes in order to keep the consistency. The only thing that I have to do is by using icon tag.
<i class="icon name" />
I've tried to create a new class and set the background image.
.new-icon {
background-image: url("./img/icon.png")
}
After that I applied that class in an icon tag like
<i class="new-icon" />
But the image didn't show at all. What I should do?

You can use <img> tag for png files but if you want to create something that you use in <i> you should create your icons as a font file, I suggest you to use <img> tag.

You should design your icon as SVG, then you can make it web fonts from here: https://fontello.com/
You can not use png as an icon.

Related

Change icon from jQuery UI to FontAwesome in PrimeFaces

I have a PrimeFaces p:tree and I was able to add font awesome expanded and collapsed icons using this, but there is an arrow icon before that which is from PrimeFaces and I was not able to figure out how to switch it font awesome arrows (fa-arrow-circle-down and fa-arrow-circle-right), or changing the color to white also suffices my need.
I have looked at the Firebug and found that the PrimeFaces arrow is from an image url("/permitweb-1.0/faces/javax.faces.resource/images/ui-icons_616161_256x240.png?ln=primefaces-aristo") I am not sure I can change the color of the image without creating or importing a new image.
I looked at other posts here because PrimeFaces was using an image and FontAwesome is CSS, I am not sure how to replace the arrow, TreeNode doesn't have a setIcon method like MenuItem.
Here is my tree code:
<p:tree selectionMode="single">
<p:treeNode expandedIcon="fa fa-folder-open" collapsedIcon="fa fa-folder">
<h:outputText value="Home" />
</p:treeNode>
<p:treeNode type="document" icon="fa fa-file-text-o fileColor">
<h:outputText value="Staff" />
</p:treeNode>
</p:tree>
Tree arrow icon:
Try my FontAwesomeResourceHandler.
This resource handler will strip the jQuery UI icons from the community PrimeFaces themes and adds FontAwesome rules to
the theme. You can use it on existing applications without needing to convert all XHTML (for example ui-icon-gear to
fa fa-cog). The injected CSS will map all the UI icons.
Add this dependency to your pom.xml:
<dependency>
<groupId>com.github.jepsar</groupId>
<artifactId>primefaces-theme-jepsar</artifactId>
<version>0.9.1</version>
</dependency>
Then, in the faces-config.xml, add the handler:
<application>
<resource-handler>org.jepsar.primefaces.theme.jepsar.FontAwesomeResourceHandler</resource-handler>
</application>
Another way I tried was using the icons from another primefaces theme which has white icon arrows. This is just another way if you find the right color for your arrow icons in another theme. Otherwise I would go for Jasper's solution for a clean one for a custom image. Just posting this an another alternative.
I am using primefaces-aristo and found white arrow icons in primefaces-black-tie, so I override the arrow icons with that theme image.
.navTree > .ui-treenode-content > .ui-tree-toggler {
background-image: url("#{resource['primefaces-black-tie:images/ui-icons_ededed_256x240.png']}");
}

Set Glyphicon as background image with css

I would like to use a glypicon using css.
The original HTML uses a background image which I would like to replace. I can't edit the html, so I want to modify the background image using css to a Glyphicon. I would like to use glyphicon glyphicon-arrow-right. I know I could replace the .gif file but I would like to avoid having to do that.
This is the HTML were I need to modify the css
<img title="My Title" class="handle icon-navigate_right medium" alt="My alt Text" src="assets/images/transparent.gif">
At the moment I have added in my css
.icon-navigate_right {background-image:none;}
and it is working, but I don't know how to now add a new background image that is a Glyphicon.
If I add something like
.icon-navigate_right:before{
content:"\2b";
font-family:"Glyphicons Halflings";
line-height:1;
margin:5px;
}
It won't display anything. Also I am not sure what content:"\2b" means.
Any help would be much appreciated.
Thanks in advance Tess

HTML/CSS: Font-Awesome Icons Not Appearing

For some reason the font-awesome social media icons refuse to show up on any browser. All other icons seem to work perfectly fine though... I've included a photo of the page opened in Mozilla with inspect element(linked due to no reputation). The only loaded css files are bootstrap and awesome-font.
It looks like you thought the text description of stacks was the class names. Icon stacks should look like this, there is no on class:
<span class="icon-stack">
<i class="icon-minus icon-stack-base"></i>
<i class="icon-camera icon-light"></i>
</span>
In your example, the second class overwrites the first class. This is because your using both classes on the same element, instead of stacking them.

How to add background image and icon to a JSF button?

I am using JSF 2.0
I am able to add Background image to the JSF button but am not able to add icon to the button.
My Requirement is:- JSF button with Background image and a Icon
Following code am using to add background.
<!-- Discard button-->
<h:commandButton action="discard" style="background-image: url('..\\Images\\leftMenuActiveBg.png');width: 150px;height: 30px;color: white;border-color: white;font-size: 15px; " value="#{message.discard}">
<rich:componentControl target="popup" operation="show" />
</h:commandButton>
Can somebody help me in adding a icon to the button too please.
I am updating a image for better Explainanation as what I want to achieve and I what I have achieved till now with above code.
So you want a button with two background images? That's not possible on a single HTML element. The <h:commandButton> generates an single HTML <input type="submit"> element, while you basically need a <button type="submit" class="background"><span class="icon"> instead. You'd need to create a custom component which generates exactly that HTML, or to adopt a 3rd party component librarty which has such a component in its set, such as PrimeFaces. See also the <p:commandButton> showcase.

Show tag icons instead of tag text in wordpress

I would like show tag icons instead of tag icons.
As an example, Instead of the tag text "Photoshop" I would like to show Photoshop icon.
Any help would be cordially appreciated.
You probably will need to make an icon for each tag, then use the tag name to build a path to the icon.
<img src="/icons/<?php echo $tagName; ?>.png" />
you could do that with tag images plugin

Resources