как добавить новый значок с SVG-файла - PullRequest
1 голос
/ 15 марта 2020

Итак, я загружаю шаблон и работаю над ним по индексу, в котором он есть:

<ul class="social">
    <li>
        <a href="">
            <span class="icon-facebook-circled"></span>
        </a>
    </li>            
    <li>
        <a href="">
            <span class="icon-twitter-circled"></span>
        </a>
    </li>
    <li>
        <a href="">
            <span class="icon-linkedin-circled"></span>
        </a>
    </li>
</ul>

Я хочу добавить значок Instagram, поэтому я делаю

<span class="icon-instagram"></span>

и добавил это строка в мой css файл

.icon-instagram:before { content: '\e9c8'; } /* '' */

, но он не показывает правильно содержимое css файла:

@font-face {
  font-family: 'porta';
  src: url('../fonts/pluton.eot?49924914');
  src: url('../fonts/pluton.eot?49924914#iefix') format('embedded-opentype'),
       url('../fonts/pluton.woff?49924914') format('woff'),
       url('../fonts/pluton.ttf?49924914') format('truetype'),
       url('../fonts/pluton.svg?49924914#porta') format('svg');
  font-weight: normal;
  font-style: normal;
}
/* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */
/* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */
/*
@media screen and (-webkit-min-device-pixel-ratio:0) {
  @font-face {
    font-family: 'porta';
    src: url('../font/porta.svg?49924914#porta') format('svg');
  }
}
*/

 [class^="icon-"]:before, [class*=" icon-"]:before {
  font-family: "porta";
  font-style: normal;
  font-weight: normal;
  speak: none;

  display: inline-block;
  text-decoration: inherit;

  text-align: center;
  /* opacity: .8; */

  /* For safety - reset parent styles, that can break glyph codes*/
  font-variant: normal;
  text-transform: none;

  /* fix buttons height, for twitter bootstrap */


  /* you can be more comfortable with increased icons size */
   /*font-size: 120%; */



  /* Uncomment for 3D effect */
  /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */
}

.icon-plus:before { content: '\e826'; } /* '' */
.icon-email:before { content: '\e825'; } /* '' */
.icon-cog:before { content: '\e823'; } /* '' */
.icon-ok:before { content: '\e80a'; } /* '' */
.icon-cancel:before { content: '\e80b'; } /* '' */
.icon-calendar:before { content: '\e10b'; } /* '' */
.icon-help-circled:before { content: '\e81a'; } /* '' */
.icon-location:before { content: '\e81b'; } /* '' */
.icon-left-open:before { content: '\e804'; } /* '' */
.icon-right-open:before { content: '\e803'; } /* '' */
.icon-up-open:before { content: '\e805'; } /* '' */
.icon-menu-1:before { content: '\e800'; } /* '' */
.icon-link-ext:before { content: '\e822'; } /* '' */
.icon-menu:before { content: '\e801'; } /* '' */
.icon-mail-alt:before { content: '\e81c'; } /* '' */
.icon-angle-left:before { content: '\e81e'; } /* '' */
.icon-angle-right:before { content: '\e81f'; } /* '' */
.icon-angle-up:before { content: '\e820'; } /* '' */
.icon-angle-down:before { content: '\e821'; } /* '' */
.icon-desktop:before { content: '\e814'; } /* '' */
.icon-mobile:before { content: '\e81d'; } /* '' */
.icon-calendar-empty:before { content: '\e802'; } /* '' */
.icon-github-circled:before { content: '\e811'; } /* '' */
.icon-vimeo-circled:before { content: '\e808'; } /* '' */
.icon-twitter-circled:before { content: '\e807'; } /* '' */
.icon-instagram:before { content: '\e9c8'; } /* '' */
.icon-facebook-circled:before { content: '\e80e'; } /* '' */
.icon-gplus-circled:before { content: '\e80d'; } /* '' */
.icon-pinterest-circled:before { content: '\e809'; } /* '' */
.icon-linkedin-circled:before { content: '\e806'; } /* '' */
.icon-dribbble-circled:before { content: '\e80f'; } /* '' */
.icon-stumbleupon-circled:before { content: '\e810'; } /* '' */
.icon-lastfm-circled:before { content: '\e812'; } /* '' */
.icon-skype-circled:before { content: '\e813'; } /* '' */
.icon-globe:before { content: '\e815'; } /* '' */
.icon-award:before { content: '\e816'; } /* '' */
.icon-user:before { content: '\e818'; } /* '' */
.icon-users:before { content: '\e819'; } /* '' */
.icon-chart-bar:before { content: '\e80c'; } /* '' */
.icon-phone:before { content: '\e824'; } /* '' */
.icon-megaphone:before { content: '\e817'; } /* '' */

1 Ответ

0 голосов
/ 15 марта 2020

Я просто тестирую большую часть вашего исходного кода, и это выглядит хорошо. Я загружаю эту бесплатную версию только здесь веб-приложение , чтобы проверить ваш источник.

Для меня похоже, что может быть проблема с вашим шрифтом. выглядит так, как будто не правильно приземлился или распознан. Но я не могу проверить это без шрифта.

Есть ли какие-либо ошибки в консоли браузера?

Обновление

Чтобы перечислить все ваши глифы В Font вы можете использовать бесплатное онлайн-приложение glyphrstudio .

  1. Выберите второй табулятор на правом сайте сверху "загрузить"
  2. Используйте кнопку "Найти файл" и выберите файл шрифта. (лучше всего ttf)
  3. Выберите последнюю опцию в списке "импортировать все глифы"
  4. С левой стороны вверху есть заголовок (выпадающий список) "Basi c Latin". Нажмите на нее и выберите «Область личного пользования»
  5. Прокрутите список / глифы, пока не найдете свой значок, и нажмите на него.
  6. В верхней части вы увидите «РЕДАКТИРОВАТЬ ГЛИФОВ >> Частное использование» Area - EF0F ", где 'EF0F' - это номер Unicode вашего глифа.

Таким образом, вы можете использовать этот номер в своей таблице стилей css:

.icon-pinterest-circled:before { content: '\ef0f'; }

Другие полезные ссылки :

Тестовый файл:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    @font-face {
      font-family: 'porta';
      src: url("./fonts/icofont.woff2?12345") format("woff2"),
           url("./fonts/icofont.woff?12345") format("woff");
      font-weight: normal;
      font-style: normal;
    }

    [class^="icon-"]:before, [class*=" icon-"]:before {
      font-family: "porta";
      font-style: normal;
      font-weight: normal;
      speak: none;

      display: inline-block;
      text-decoration: inherit;

      text-align: center;
      /* opacity: .8; */

      /* For safety - reset parent styles, that can break glyph codes*/
      font-variant: normal;
      text-transform: none;

      /* fix buttons height, for twitter bootstrap */


      /* you can be more comfortable with increased icons size */
      /*font-size: 120%; */



      /* Uncomment for 3D effect */
      /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */
    }

    .icon-plus:before { content: '\e826'; } /* '' */
    .icon-email:before { content: '\e825'; } /* '' */
    .icon-cog:before { content: '\e823'; } /* '' */
    .icon-ok:before { content: '\e80a'; } /* '' */
    .icon-cancel:before { content: '\e80b'; } /* '' */
    .icon-calendar:before { content: '\e10b'; } /* '' */
    .icon-help-circled:before { content: '\e81a'; } /* '' */
    .icon-location:before { content: '\e81b'; } /* '' */
    .icon-left-open:before { content: '\e804'; } /* '' */
    .icon-right-open:before { content: '\e803'; } /* '' */
    .icon-up-open:before { content: '\e805'; } /* '' */
    .icon-menu-1:before { content: '\e800'; } /* '' */
    .icon-link-ext:before { content: '\e822'; } /* '' */
    .icon-menu:before { content: '\e801'; } /* '' */
    .icon-mail-alt:before { content: '\e81c'; } /* '' */
    .icon-angle-left:before { content: '\e81e'; } /* '' */
    .icon-angle-right:before { content: '\e81f'; } /* '' */
    .icon-angle-up:before { content: '\e820'; } /* '' */
    .icon-angle-down:before { content: '\e821'; } /* '' */
    .icon-desktop:before { content: '\e814'; } /* '' */
    .icon-mobile:before { content: '\e81d'; } /* '' */
    .icon-calendar-empty:before { content: '\e802'; } /* '' */
    .icon-github-circled:before { content: '\e811'; } /* '' */
    .icon-vimeo-circled:before { content: '\e808'; } /* '' */
    .icon-twitter-circled:before { content: '\ef52'; } /* '' */
    .icon-instagram:before { content: '\e9c8'; } /* '' */
    .icon-facebook-circled:before { content: '\eea2'; } /* '' */
    .icon-gplus-circled:before { content: '\e80d'; } /* '' */
    .icon-pinterest-circled:before { content: '\e809'; } /* '' */
    .icon-linkedin-circled:before { content: '\ef53'; } /* '' */
    .icon-dribbble-circled:before { content: '\e80f'; } /* '' */
    .icon-stumbleupon-circled:before { content: '\e810'; } /* '' */
    .icon-lastfm-circled:before { content: '\e812'; } /* '' */
    .icon-skype-circled:before { content: '\e813'; } /* '' */
    .icon-globe:before { content: '\e815'; } /* '' */
    .icon-award:before { content: '\e816'; } /* '' */
    .icon-user:before { content: '\e818'; } /* '' */
    .icon-users:before { content: '\e819'; } /* '' */
    .icon-chart-bar:before { content: '\e80c'; } /* '' */
    .icon-phone:before { content: '\e824'; } /* '' */
    .icon-megaphone:before { content: '\e817'; } /* '' */
  </style>
</head>
<body>
  <ul class="social">
    <li>
        <a href="">
            <span class="icon-facebook-circled"></span>
        </a>
    </li>            
    <li>
        <a href="">
            <span class="icon-twitter-circled"></span>
        </a>
    </li>
    <li>
        <a href="">
            <span class="icon-linkedin-circled"></span>
        </a>
    </li>
</ul>
</body>
</html>
...