I don't know why but only in production some material icon doesn't appear, as you can see from the image the first icon is missing:
here's the code:
<mat-nav-list>
<a mat-list-item routerLink="/dashboard" matTooltip="dashboard">
<mat-icon matListIcon>bar_chart</mat-icon>
</a>
<a mat-list-item (click)="routeToContacts()" matTooltip="contacts">
<mat-icon matListIcon>people</mat-icon>
</a>
You need to insert style into the project:
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
If it did not solve the problem, please try to add the code below in your style.css (or style.scss) :
md-icon{
font-family: 'Material Icons' !important;
}
If you are using SASS and have opacity set to a percentage like
mat-icon {
opacity: 50%;
padding-right: 0.5em;
}
The icons might "disappear" in production builds because a SASS rule. The result is your opacity is 0% or 1% in the CSS files produced.
Changing the opacity to a decimal will give you the result you were expecting.
mat-icon {
opacity: 0.5;
padding-right: 0.5em;
}
Had a similar issue, the icon event_repeat appearad as two wrong icons in production build but worked in development build. The build process changes how fonts are embedded. In my case an old version of the woff2-file was loaded (v109 instead of the current v121). The appropriate css in the folder node_modules\.cache\angular-build-fonts, so I deleted node_modules and ran cmp ci. That fixed this issue.
Related
I'm trying to use the following CSS and the hover effect doesn't work if I'm viewing the HTML/CSS locally via liveserver in VSCode, or simply opening the HTML file from the file explorer. It also doesn't work if I upload the HTML/CSS files to a server. However, if I place the exact HTML and CSS in CodePen, the hover effect works just fine.
When I'm viewing it locally or on a server (where the hover doesn't work) and I toggle the hover state on in Chrome DevTools, it acts like there is no CSS for the hover state, but if I toggle the Focus state on, it indeed works as expected and applies the CSS.
Why would this hover effect work in CodePen - here - https://codepen.io/stemlund/pen/BadGJZy, but not locally or when uploaded to a server?
.dot-indicators>* {
cursor: pointer;
border: 0;
border-radius: 50%;
aspect-ratio: 1;
padding: 0.5em;
background-color: red;
}
.dot-indicators>*:hover,
.dot-indicators>*:focus {
background-color: green;
}
<div class="dot-indicators flex">
<button aria-selected="true"><span class="sr-only">Slide title</span></button>
<button aria-selected="false"><span class="sr-only">Slide title</span></button>
<button aria-selected="false"><span class="sr-only">Slide title</span></button>
</div>
There are (at least) two ways of showing a bitcoin symbol.
One is to use font awesome and style that if you wish:
.fa-btc {
font-size: 75%;
color:#6f42c1;
opacity: 0.8;
vertical-align: -5%;
font-variant: small-caps;
}
The other is to just show the new Unicode character 20BF:
.bitcoin::before {
font-size: 80%;
opacity: 0.8;
vertical-align: 10%;
content: "\20BF";
}
I like the unicode way better. It's more subtle I guess.
But it doesn't work on Android yet. The Roboto and Nono fonts which apparently do the rendering on Android web browsers don't have it yet.
Note that I am downloading a font for my site which does have the symbol, so I'm perplexed why Android is not using it:
<!--website font-->
<link href="https://fonts.googleapis.com/css?family=Roboto|Roboto+Mono" rel="stylesheet">
What would be a way to detect and display the fa icon in these cases where the unicode isn't available?
Ideally, I'd like to key off of the unicode symbol being available in the font which is actually used, as opposed to just looking at the OS or other things which may or may not coincide with the symbol being available. Finding and using a certain font that has this symbol when I'm on Android OS would be a good answer too. I didn't tag Android because this isn't Android development; that just happened to be the environment that alerted me to the issue.
I combined a couple of answers regarding detecting tofu characters and replacing ::before content , and came up with this.
Text-based solution
Doesn't need code fix once Android starts working
$(document).ready(function(){
var bitcoinSymbolAvailable = document.getElementById('char-to-check').offsetWidth !== document.getElementById('not-renderable').offsetWidth;
if(!bitcoinSymbolAvailable)
$('body').append('<style>.bitcoin:before{content:"\\0E3F" !important;}</style>');
});
.bitcoin::before {
font-size: 80%;
opacity: 0.8;
vertical-align: 10%;
content: "\20BF"; /* \0E3F */
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
<img width="200" src="https://img.cinemablend.com/filter:scale/quill/9/a/d/3/5/0/9ad35052cecea0ff468e2f03476d9e8e385add82.jpg?mw=600">
<h1>But first you must pay me... <span class="bitcoin">1,000,000</span>
</div>
<div style="position:absolute;visibility:hidden;">
<span id="char-to-check">₿</span>
<span id="not-renderable"></span>
</div>
I am unable to edit this font from FontAwesome. When I add <i class="fas fa fa-child"></i> to my code I can see the child figure. But when I added this to my CSS:
.fa {
background-color: green;
color: red;
}
But, nothing happened to the child icon. I know this is something little but I can't figure out how to solve the issue.
FontAwesome5 that you are using is SVG based, so u need to edit it like SVG.
Visit - https://css-tricks.com/using-svg/
I am using a WordPress theme called Divi. This isn't a WordPress question. There are a number of provided social media icons, but I need a Soundcloud icon, and that is not provided. I'm not understanding how these icons are populating the page as they don't seem to be graphics, but rather are a font? However, I am unable to tell from the source code what is going on (inexperience).
What I'm trying to do is either add an icon of my design, or replace an existing icon. Can someone help point me in the direction if where I should be looking within my files to find the actual icons?
You can see a live site here and the icons are at the top right:
http://rattletree.com/wordpress2/
The dev code has this for the Facebook icon:
<ul class="et-social-icons">
<li class="et-social-icon et-social-facebook">
<a href="#" class="icon">
<span>Facebook</span>
</a>
</li>
</ul>
And the css has this:
.et-social-facebook a.icon:before {
content: "\e093";
}
#top-header .et-social-icon a {
font-size: 14px;
}
So that makes me think this is a font, but I don't know how or where I can edit that font? Thanks for any help!
This looks like the font pack you are using:
http://www.elegantthemes.com/blog/resources/elegant-icon-font
It doesn't look like it has an icon for soundcloud, but you could use the cloud one:
So just add this to the style sheet:
.et-social-soundcloud a.icon:before {
content: "\e002";
}
Also, here's a tutorial:
https://www.elegantthemes.com/blog/resources/how-to-use-and-embed-an-icon-font-on-your-website
To add an icon of your design, add the following code to your stylesheet.
#top-header .et-social-icon.soundcloud a {
width: 15px;
height: 25px;
}
.soundcloud a.icon:before {
content: "";
background: url('https://placehold.it/15x25') 100% 100% no-repeat;
height: 100%;
width: 100%;
display: inline-block;
}
Make sure you create an icon, add the icon image to theme folder and update the url in the above code to point to that image.
Also add the class soundcloud to your menu in WordPress backend.
I'm displaying one of the Twitter Bootstrap provided icons in an anchor. I want the default icon to be switched to icon-white when i have the mouse over the anchor.
The effect should be like when you hover over the anchors in the navbar here
How is this done?
You use the CSS pseudo-class :hover to set a different background:
.menulink:hover { background-image: url('alternative_sprite.png'); }
Use jQuery toggleClass() on hover to change the icon to white.
See this jsfiddle.
HTML:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
<a href="#"><div class="btn btn-primary">
<i class="glyphicon glyphicon-print"></i> Click</div></a>
<br/>
Script:
$("document").ready(function(){
$("a").hover(function(){
$('i').toggleClass('glyphicon-envelope glyphicon-print');
});
});
just switch over the glyphicons image?
(extracted from my css, which is a sass version, and my images are in a different place, but you get the idea...)
&:hover{
i{
background-image: url("../images/bootstrap/glyphicons-halflings-white.png");
}
Actually, the AngularJS website uses a webfont to display icons:
font-family: 'FontAwesome';
And they insert the font-icon using CSS pseudo-class :before:
[class^="icon-"]:before, [class*=" icon-"]:before {
font-family: FontAwesome;
}
Which it is a brilliant solution, if you resolve to create your own icon web font.
Or even better, you can use Font-Awesome.
Use CSS psuedo-class :hover..
.menulink:hover { background-image: url('myimage.png'); }
Some of the answer above are not working and give a background image with all glyphicons at ones.
This works form me. Notice that I have changed the color of the icons to fits my needs.
a:hover > [class^="icon-"] {
background-image: url("bootstrap/img/glyphicons-halflings-orange-dark.png") !important;
}
I know there are already a few quick solutions posted that will do the trick. I would like to add my solution if you would like to achieve this without using JQuery or CSS:
Crate an $scope object that contains the name of the icon class your would like to set by default.
$scope.myClass = "glyphicon glyphicon-ok"
Add ng-class directive and get the class name from $scope.MyClass, add ng-mouseover and ng-mouseleave directives and change $scope.MyClass value
<span
ng-class="myClass"
ng-mouseover="myClass = 'glyphicon glyphicon-remove'"
ng-mouseleave="myClass = 'glyphicon glyphicon-ok'">
</span>