How to add google icon font to pseudo: before

I am using google material design icon fonts.

However, I want to overlay one fone on top of the other. The idea is to add a: before or: after element and create it something like this:

.material-icons:before
{
    position:absolute;
    content:"";
    color:@accent-color;
    font-size:2.4rem;
}

      

However, I'm not sure how to enable this &#xE84E

:; to the content attribute - I've tried several ways and also used a CSS trick converter (which doesn't seem to work).

Any help was appreciated.

+3


source to share


2 answers


In CSS, to indicate a character that you would otherwise escaped in HTML &

, such as; ✏

, you have to use escape \

eg content: "\9999"

.

.material-icons:before {
     position: absolute;
     content: "\E84E";
     color: #882288;
     font-size: 2.4rem;
}

      



To end an escaped character explicitly, use another \

, for examplecontent: "\E84E\ Hello World";

+10


source


You can achieve this by specifying the original Google Font css class which:

.material-icons {
    font-family: 'Material Icons';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;  /* Preferred icon size */
    display: inline-block;
    width: 1em;
    height: 1em;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;
    /* Support for all WebKit browsers. */
    -webkit-font-smoothing: antialiased;
    /* Support for Safari and Chrome. */
    text-rendering: optimizeLegibility;
    /* Support for Firefox. */
    -moz-osx-font-smoothing: grayscale;
    /* Support for IE. */
    font-feature-settings: 'liga';
}

      



Using SASS, you can extend it and set the content with a pseudo-css element:

ul
    &:before {
        @extend .material-icons;
        content: 'label';
    }
}

      

+2


source







All Articles