3

问题

<a>我在其上应用了 fontello.com 的字体图标的标签在网页上呈现如下,尽管它应该是这个左箭头或右箭头

在此处输入图像描述

背景

将此答案中的前四点用作使用fontello.com字体的教程。我不完全理解第五点(<i>标签部分),但它也是可选的。

...........

我需要一个<a>元素上的独立(即不带文本)字形图标,所以我这样做了:

<a href="" class="left-arrow icon-angle-left"></a>

<a href="" class="right-arrow icon-angle-right"></a>

在这个<a>元素的 CSS 中:

.right-arrow, .left-arrow {
    font-family: 'arrows';
    ...
}

…………

这是从 fontello.com 下载arrows.css的文件夹中的文件:CSS

@font-face {
  font-family: 'arrows';
  src: url('../font/arrows.eot?42097229');
  src: url('../font/arrows.eot?42097229#iefix') format('embedded-opentype'),
       url('../font/arrows.woff?42097229') format('woff'),
       url('../font/arrows.ttf?42097229') format('truetype'),
       url('../font/arrows.svg?42097229#arrows') 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: 'arrows';
    src: url('../font/arrows.svg?42097229#arrows') format('svg');
  }
}
*/

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

  display: inline-block;
  text-decoration: inherit;
  width: 1em;
  margin-right: .2em;
  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 */
  line-height: 1em;

  /* Animation center compensation - margins should be symmetric */
  /* remove if not needed */
  margin-left: .2em;

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

  /* Font smoothing. That was taken from TWBS */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

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

.icon-angle-right:before { content: '\e800'; } /* '' */
.icon-angle-left:before { content: '\e801'; } /* '' */

编辑@Pauli_D

是的,我在那里。我创建了一个小演示项目我不知道如何在 JSFiddle 中添加 fontello,所以在这里发布代码):

索引.php:

<?php  

echo '<!DOCTYPE html>
<html>
    <head>      
        <meta charset="utf-8"/>
        <title>Test for Glyph Icon from Fontello</title>
        <link rel="stylesheet" type="text/css" href="style.css"/>
        <link rel="stylesheet" type="text/css" href="arrows.css"/>
    </head>
    <body>';

        echo '<a href="" class="right-arrow icon-angle-right"></a>';

        echo '<br><br><br>';

        echo '<a href="" class="left-arrow icon-angle-left"></a>';

    echo '</body>
    </html>';

?>

样式.css:

.right-arrow, .left-arrow {
    font-family: 'arrows';
    color: #313131;
    text-align: center;
    text-decoration: none;
    width: 40px;
    font-size: 40px;
    padding-bottom: 60px;
    padding-top: 20px;
    filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=60);
    opacity: 0.6;
    -webkit-transition: opacity 0.3s ease;
    -moz-transition: opacity 0.3s ease;
    -o-transition: opacity 0.3s ease;
    transition: opacity 0.3s ease;
}

arrows.css 同上

.....................

在此处输入图像描述

4

2 回答 2

1

尝试

<a href=""><i class="left-arrow icon-angle-left"></i></a>
<a href=""><i class="right-arrow icon-angle-right"></i></a>

第 5 步仅指对您的图标应用零边距。


编辑:

保留您<a>现在拥有的元素,无需编辑。

编辑 arrows.css 文件中../的路径并从路径的开头删除。

@font-face {
font-family: 'arrows';
src: url('font/arrows.eot?42097229');
src: url('font/arrows.eot?42097229#iefix') format('embedded-opentype'),
     url('font/arrows.woff?42097229') format('woff'),
     url('font/arrows.ttf?42097229') format('truetype'),
     url('font/arrows.svg?42097229#arrows') format('svg');
font-weight: normal;
font-style: normal;
}
于 2015-05-27T12:13:19.750 回答
0

因为您使用的是免费的“演示”字体,因此必须将“演示图标”类添加到您添加每个图标的每个类中。例子:

<i class="demo-icon left-arrow icon-angle-left"></i>

于 2022-02-16T13:32:26.590 回答