问题
我在fontello.com上应用了字体图标的<a>
标记在网页上呈现,虽然它应该是这个或右箭头:
背景
我使用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';
...
}
.........
以下是从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,所以在这里发布代码):
的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与上述相同
..............
答案 0 :(得分: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;
}