Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 为什么我的@font-face不起作用?_Html_Css_Fonts_Font Face - Fatal编程技术网

Html 为什么我的@font-face不起作用?

Html 为什么我的@font-face不起作用?,html,css,fonts,font-face,Html,Css,Fonts,Font Face,我不明白为什么这个代码对我不起作用。我试图在我的标签上添加图标,但当我从我的网站文件中调用字体时,它们似乎对我试图放入的任何内容都不起作用。我正试图在我的.showMenu中插入一个图标,但由于某些原因,它无法工作。我已经将字体文件上传到我的服务器上,@font-face中的url是正确的,但它不想工作。请帮忙 HTML: 我四处寻找,发现每个字体文件都需要一个完整的文件路径,而不是一个缩短的路径。 下面是它的外观: CSS: 看起来您的路径不正确。尝试: src:url('../fonts/i

我不明白为什么这个代码对我不起作用。我试图在我的标签上添加图标,但当我从我的网站文件中调用字体时,它们似乎对我试图放入的任何内容都不起作用。我正试图在我的.showMenu中插入一个图标,但由于某些原因,它无法工作。我已经将字体文件上传到我的服务器上,@font-face中的url是正确的,但它不想工作。请帮忙

HTML:


我四处寻找,发现每个字体文件都需要一个完整的文件路径,而不是一个缩短的路径。 下面是它的外观:

CSS:


看起来您的路径不正确。尝试:

src:url('../fonts/icomoon/icomoon.eot');
src:url('../fonts/icomoon/icomoon.eot?#iefix') format('embedded-opentype'),
    url('../fonts/icomoon/icomoon.ttf') format('truetype'),
    url('../fonts/icomoon/icomoon.woff') format('woff'),
    url('../fonts/icomoon/icomoon.svg#typicons') format('svg');

您确定您的浏览器版本支持@font-face吗?你可以在:是的。我在所有最新的浏览器中都尝试过。你确定你的字体文件路径在父目录中而不是css样式中吗?你给出的相对路径正确吗?我的父目录中有一个字体文件夹和一个css文件夹,我的字体是公开的,html/fonts/icomoon,css是公开的,html/css/index\U样式表,你认为这会有什么不同吗?我很困惑,因为这种字体昨天在我的网站的旧版本上运行,但现在我已经开始更新它,它似乎不起作用。
@font-face {

font-weight: normal;

font-style: normal;

font-family: 'icomoon';

src:url('../fonts/icomoon/icomoon.eot');
src:url('../fonts/fonts/icomoon/icomoon.eot?#iefix') format('embedded-opentype'),
    url('../fonts/fonts/icomoon/icomoon.ttf') format('truetype'),
    url('../fonts/fonts/icomoon/icomoon.woff') format('woff'),
    url('../fonts/fonts/icomoon/icomoon.svg#typicons') format('svg');

}

.showMenu {

font-size: 22px;

padding-left: 10px;

padding-right: 10px;

background: #ed8151;

font-family: 'icomoon';

border: 1px solid #e86a32;

border-radius: 3px;

}

.showMenu:before {

content: "\e6b8"

}
@font-face {

font-weight: normal;

font-style: normal;

font-family: 'icomoon';

src:url('http://yoursite.com/fonts/icomoon/icomoon.eot');
src:url('http://yoursite.com/fonts/icomoon/icomoon.eot?#iefix') format('embedded-opentype'),
    url('http://yoursite.com/fonts/icomoon/icomoon.ttf') format('truetype'),
    url('http://yoursite.com/fonts/icomoon/icomoon.woff') format('woff'),
    url('http://yoursite.com/fonts/icomoon/icomoon.svg#typicons') format('svg');

}
src:url('../fonts/icomoon/icomoon.eot');
src:url('../fonts/icomoon/icomoon.eot?#iefix') format('embedded-opentype'),
    url('../fonts/icomoon/icomoon.ttf') format('truetype'),
    url('../fonts/icomoon/icomoon.woff') format('woff'),
    url('../fonts/icomoon/icomoon.svg#typicons') format('svg');