gpt4 book ai didi

css - 为什么 fontello 的字体图标呈现为空框?

转载 作者:行者123 更新时间:2023-11-28 10:15:12 27 4
gpt4 key购买 nike

问题

<a>我在网页上应用了来自 fontello.com 的字体图标的标签 像这样呈现虽然它应该是这个左箭头或右箭头:

enter image description here

背景

我用了the first four points from this answer作为使用 fontello.com 字体的教程.我不完全理解第 5 点(<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';
...
}

…………

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

@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,所以在这里发布代码):

index.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>';

?>

style.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 同上

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

enter image description here

最佳答案

尝试

<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;
}

关于css - 为什么 fontello 的字体图标呈现为空框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30481900/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com