2013-02-20 84 views
-1

我试图用@字体面第一次,但它不工作任何人可以帮助我解决这个问题 为什么这个脚本不工作CSS @字体面不工作

<style> 
    @font-face{ 
     font-family: myfont; 
     src: url('entypo.eot'); 
     src: url('entypo.eot?iefix') format('eot'), 
      url('entypo.woff') format('woff'), 
      url('entypo.ttf') format('truetype'), 
      url('entypo.svg#helvetica') format('svg'); 
     font-weight: normal; 
     font-style: normal; 
    } 

    div { 
     font-family: myfont; 
    } 
</style> 

</head> 
<body> 
    <div> 
      sdfdfdsfsdf 
    </div> 
+0

哪里的字体从何而来?你是如何制作不同的格式的?你确定你上传了这些文件吗?哪里?你测试过哪些浏览器? “不工作”是什么意思? – 2013-02-20 07:22:22

回答

0

试试这个

@font-face 
{ 
    font-family: 'SegoeUI'; 
    src: url('Fonts/segoeui.eot'); 
    src: url('Fonts/segoeui.eot?#iefix') format('embedded-opentype'), url('fonts/segoeui.ttf') format('truetype'); 
} 

@font-face 
{ 
    font-family: 'SegoeLight'; 
    src: url('Fonts/segoeuil.eot'); 
    src: url('Fonts/segoeuil.eot?#iefix') format('embedded-opentype'), url('fonts/segoeuil.ttf') format('truetype'); 
} 
0

我认为你的字体不是英文字体,对吗?无论如何。我面对这个问题很多,因为我使用波斯语字体,有时他们不工作!我所做的是用不同的软件,如在线字体转换器,将它们重新转换成不同的字体格式。有时候我的字体可以在IE,Firefox中使用,但不能使用chrome!然后我重新转换它们,一切都变成正常!所以重新转换它们可能会解决您的问题。 PS:一些很酷的网站做这样一件事:
font face generator
font 2 web

+0

是的,它不是英文字体。其免费的图标字体,我从网上下载 – shinosn 2013-02-21 05:47:11

+0

@shinosn所以我想我的答案是你的 – 2013-02-23 19:35:26

0

添加'到myfont,并改变helveticamyfont这样的:

@font-face{ 
    font-family: 'myfont'; 
    src: url('entypo.eot'); 
    src: url('entypo.eot?iefix') format('eot'), 
     url('entypo.woff') format('woff'), 
     url('entypo.ttf') format('truetype'), 
     url('entypo.svg#myfont') format('svg'); 
    font-weight: normal; 
    font-style: normal; 
} 

div { 
    font-family: 'myfont'; 
} 
0

你的字体应该放在有关如果CSS在单独的文件夹中使用相关路径

例如

// Directory Structure 
images 
css 
fonts 
-index.html 

如果你的字体是在其他文件夹中的文件夹和CSS使用下面的CSS

@font-face{ 
    font-family: 'myfont'; 
    src: url('../fonts/entypo.eot'); 
    src: url('../fonts/entypo.eot?iefix') format('eot'), 
     url('../fonts/entypo.woff') format('woff'), 
     url('../fonts/entypo.ttf') format('truetype'), 
     url('../fonts/entypo.svg#myfont') format('svg'); 
    font-weight: normal; 
    font-style: normal; 
}