我在标签中集成了各种自定义字体,在 FF 中运行良好,但在 web-kit 浏览器(如(chrome 和 safari))中无法运行。
<select>
<option value="" style="font-family: 'Averia Libre'!important;">I'm a custom font.</option>
<option value="" style="font-family: 'cancun', cursive;">Hey me too!</option>
<option value="" style="font-family: 'Averia Libre', cursive!important;">Averia Libre</option>
</select>
jsfiddle demo here.
您可以为 option
创建 CSS 类,它使用使用 @font-face 定义的特定字体。
例如,如果您在 CSS 中定义了以下 @font-face
@font-face
{
font-family: "MyFont1";
src: url('Averia_Libre.ttf'),
url('Averia_Libre.eot'); /* IE9 */
}
@font-face {
font-family: "MyFont2";
src: url('cancun.ttf');
}
option.style1{
font-family: MyFont1;
}
option.style2{
font-family: MyFont2;
}
您的 HTML 代码应该是
<select>
<option value="" class="style1">I'm a custom font.</option>
<option value="" class="style2">Hey me too!</option>
</select>
请注意,我还没有测试代码,可能它应该可以工作,因为很久以前我在我记得的一项任务中就这样做过。