I am working on Servicenow service portal where i created a custom icon-link widget that displays the image as glyph icon.
I almost got everything but my image is stylying as-is comparing to glyph icon.
/* CIRCLE ICON ---------- */
a.circle_icon {
display: block;
padding: 20px 0px 20px 70px;
position: relative;
}
a.circle_icon .fa {
position:absolute;
left: 0px;
top: 10px;
}
/* Image Circle ------- */
a.image_icon {
display: block;
padding: 20px 0px 20px 70px;
position: relative;
}
a.image_icon .fa {
position:absolute;
left: 0px;
top: 10px;
}
<!--// Circle Icon -->
<a ng-if="::(options.link_template == 'Circle Icon')" ng-href="{{::data.href}}" class="circle_icon {{::options.class_name}} text-{{::options.color}}" target="{{::data.target}}">
<span class="fa fa-stack fa-2x">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-{{::options.glyph}} fa-stack-1x fa-inverse"></i>
</span>
<h2>{{::options.title}}</h2>
<span class="text-muted">{{::options.short_description}}</span>
</a>
<!--// Image Icon -->
<a ng-if="::(options.link_template == 'Image Icon')" ng-href="{{::data.href}}" class="image_icon {{::options.class_name}} text-{{::options.color}}" target="{{::data.target}}">
<span class="fa fa-stack fa-2x">
<img src="{{data.target}}"/>
</span>
<h2>{{::options.title}}</h2>
<span class="text-muted">{{::options.short_description}}</span>
</a>
With this code my output looks like this.
Click here
Circle Icon is Out of the box and Image icon is my custom code. I want the aeroplance image looks same as above Get help and Community icon.
I have a few followup questions for you.
1.What is the reason for creating a new widget? (Instead of using Icon link OOB widget)
I'm assuming you wanted to have a custom image in place of the
bootstrap icon.
if yes there is an alternate solution without cloning also you can use your custom image. (Using page in designer add a class, Write style[custom image css] and that's it, without cloning its possible)
2.With the OOB Icon link widget, you can do that with instance options, if you cloned the OOB Icon link widget you can go to instance options add modify,
How to do that?
Right-click on the widget, go to instance options.
scroll to the bottom last field Template has the option as 'Circle icon'
Save and done (Please refer to screenshots attached below)
Related
I am currently a student learning HTML and CSS. I was tasked with an assignment to replicate a single webpage. However, I am having difficulties getting the icons to look like what is shown in the model provided to replicate. The images below show what the icon area of the model should look like versus what I have, and also what the original icons looked like when just added to the HTML before color or size adjustments were made.
Original icon area of the model provided.
How close I have gotten to it
Original icons before size and color adjustments were made
I need to get the edges to be sharp and the white areas above and below the icons to be removed. I tried setting the border-radius, margin, and padding to 0px or 0% and nothing still works. I also tried using text-shadow.
My HTML code for the icon area is
'<div class="icons">
<i class="fab fa-twitter-square"></i>
<i class="fab fa-facebook-square"></i>
<i class="fab fa-dribbble-square"></i>
<i class="fab fa-tumblr-square"></i>
<i class="fas fa-rss-square"></i>
</div>'
And CSS
'i{
display: inline-flexbox;
font-size: 24px;
color: #3E5A99;
background-color: #E5EEFF;
margin-bottom: 50px;
}'
I am asking for some advice on how to get this done, please. Thank you in advance.
The short answer is no, you cannot edit the FontAwesome webfont icons without downloading, editing, and reuploading the individual svgs.
I would use the background-less versions of these icons and then put them each inside a div. Then you can set the div border-radius, background-color, etc. to exactly what you need.
A couple of pointers with this process:
Use display: grid; for each container div, that way you can also add place-items: center; to super-center each icon inside of it's div.
Many of my links have material icons in tags inside the link. Now, Google has indexed my page with site-links that include the text/ligature from that material-icons tag, so a link might say "shopping_cart Shop Now" for example.
Everything already displays correctly when browsing the site, but it's just in google's search results that the page titles look ridiculous.
<li>
<a href="/feed.php">
<i class="material-icons icon">shopping_cart</i>
<span>Shop Now</span>
</a>
</li>
I would not expect the text "shopping_cart" to appear when Google indexes these page titles for site-links. How can I tell Google to stop doing that?
You can't tell Google to stop indexing that. What you can do is remove what you don't want Google to index. For example, if you don't want it indexing the material icon text then remove the material-icons class and text from the HTML.
What you can do instead is add it via CSS with a pseudo class, here's a pen for example: https://codepen.io/MatthewRader/pen/VNZxdo
your HTML and CSS would look like this:
<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet">
<li>
<a href="/feed.php">
<span>Shop Now</span>
</a>
</li>
li {
list-style:none;
}
a {
text-decoration: none;
color: PeachPuff;
padding: 10px;
background: SaddleBrown;
}
a::before {
font-family: 'Material Icons';
content: "shopping_cart";
-webkit-font-feature-settings: 'liga';
}
Im trying to use an fa-cog as a button that opens a popover in AngularJS using Angular UI. I realise this is possible using js/jQuery, but I am looking for a css/html solution.
HTML:
<span
class="fa fa-cog fa-2x"
uib-popover-template="'popoverTemplate.html'"></span>
CSS:
fa.cog{
color: grey;
}
fa.cog:hover{
color: black;
}
//Doesn't work
fa.cog :active or :focus or :target etc.{
color: black
}
What I am trying to do is, when the popover is not showing, the cog should have the color grey. When the popover is open, the cog should be black.
I've tried css selectors like fa-cog:active and fa-cog:focus, but they didn't do much.
Unsure how i can achieve this, any ideas?
The popover directive has a helper attribute called tooltip-is-open, it provides you with a read-only variable that tell you if the popover is open or not.
Then you can use either ngClass or ngStyle to conditionally apply your css
<span class="fa fa-cog fa-2x"
uib-popover-template="'popoverTemplate.html'"
popover-is-open="iAmOpen"
ng-class="{'active': iAmOpen}">
</span>
this should work
fa.cog{
color: grey;
}
fa.cog:hover{
color: black;
}
fa.cog:active, fa.cog:focus{
color: grey;
}
you are setting black color when active or focused, not grey
My goal is to come up with a dropdown menu:
$(document).on('click', '.dropdown', function() {
var is_visible = $(this).find('.dropdown-content').is(":visible");
$('.dropdown-content').toggle(false);
if (is_visible == false){
$(this).find('.dropdown-content').toggle(true);
}
});
.dropdown {
position: relative;
display: inline-block;
cursor: pointer;
}
div.dropdown-content {
display: none;
white-space: nowrap;
position: absolute;
padding: 12px 16px;
z-index: 1;
margin-top: 15px;
background: white;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class='dropdown'>
<i class="fa fa-ellipsis-h fa-lg" aria-hidden="true"></i>
<div class="dropdown-content">
<div><i class="fa fa-share-alt" aria-hidden="true"></i> Share</div>
<div><i class="fa fa-trash-o fa-fw"></i> Delete</div>
</div>
</div>
The question is, what is the semantic role of <a> tag in the dropdown-content item definition (provided I don't use its href attribute and use JavaScript to handle the click event)?
In other words: if I want to have a clickable icon, in which cases should I surround it with an <a> tag?
if I want to have a clickable icon, in which cases should I surround it with <a> tag?
The only case where you should wrap anything with an <a> tag is if it's a link, or a placeholder for where a link could be.
Otherwise, if you want to make something clickable, the appropriate element is <button type="button">.
The one exception to that is if you need to wrap anything that's not phrasing content, in which case I recommend using <div role="button" tabindex="0> with a keydown handler to trigger click events on Enter, and Space.
Additional notes about accessibility for icons, and icon fonts in general: If a network request fails and the icon font fails to load, your sighted users will find themselves in the same situation as your non-sighted users, where it's unclear as to what the button should do.
Generally speaking it's better to pair icons with textual labels, but if that's not possible, consider using an <img> element with [alt] text instead of the icon.
If that's not possible, at least add an [aria-label] attribute.
I'm trying to set a custom icon for my Universal app's appbar. Segoe UI Symbol just doesn't have everything I'm after. I would like to use FontAwesome. Unfortunately, I can't figure out how to do that.
The only official way I can find to put custom icons into an app bar is to use PNGs, but these do not scale as well as font-awesome and are awkward to make.
The closest I've come is to create a div based element on the appbar which looks like an appbar button:
<div data-win-control="WinJS.UI.AppBarCommand"
data-win-options="{ id:'btnLab',label:'Lab', section:'global', type:'content'}">
<div id="itemContainer" data-win-control="WinJS.UI.ItemContainer">
<i class="fa fa-flask" style="color: #000; font-size: 19px;
padding: 10px; border: 2px solid #222; border-radius: 50%;">
</i>
<br/>
<span style="color: #000; font-size: 12px;">Lab</span>
</div>
</div>
This produces something pretty close to an appbar button, which is clickable and can be assigned a behaviour
With some tweaking I believe I could get this to look identical to a button, however I'm not confident it will scale the same way that normal app bar buttons do. Also when hovering there is this nasty border around it:
Does anyone know how I can just use font-awesome, or some other font based icon set, directly in a button?
I've found an answer for this - it can be done quite easily using script. I used the DOM inspector to find that the actual HTML for the button image is like so
<button class="win-disposable win-command win-global" id="cmdKey" role="menuitem"
aria-label="Key" type="button" data-win-options="{id:'cmdKey',label:'Key',icon:'',
section:'global',tooltip:'testing out font-awesome'}"
data-win-control="WinJS.UI.AppBarCommand">
<span tabindex="-1" class="win-commandicon win-commandring"
aria-hidden="true">
<span tabindex="-1" class="win-commandimage" aria-hidden="true"
style="-ms-high-contrast-adjust: none;"></span>
</span>
<span tabindex="-1" class="win-label" aria-hidden="true">
Key
</span>
</button>
You can very easily target win-commandimage using either jQuery or straight JS and put a font-awesome icon directly in there
$('#cmdKey .win-commandimage').html('<i class="fa fa-key"></i>');
I find the icons a little small, but this can easily be fixed with CSS
#cmdKey .win-commandimage
{
font-size: 20px;
}
I encountered this issue yesterday.
<div data-win-control="WinJS.UI.AppBar" id="appBar" data-win-options="{placement: 'bottom'}" style="overflow: hidden;">
<button class="fa fa-flask" style="font-size: 2em; padding-bottom: 15px;" data-win-control="WinJS.UI.AppBarCommand" data-win-options="{id: 'flaskBtn', section:'global', label: 'Lab', tooltip:'Lab'}"></button>
</div>
Javascript:
var myAppBar = element.querySelector("#appBar");
myAppBar.winControl.closedDisplayMode = "full";
This worked for me. To enlarge the font size, I had to use style="font-size: 2em" -- for some reason, the larger icon classes (fa-lg, fa-2x, fa-3x, fa-4x) don't work when declared in a class and it's within an AppBar.
class="fa fa-flask fa-2x" works if you create a Font Awesome element outside of an AppBar.