对< SELECT>的CSS字体家族支持已删除在Firefox中? [英] CSS Font-Family Support Dropped for <SELECT> in Firefox?

查看:95
本文介绍了对< SELECT>的CSS字体家族支持已删除在Firefox中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下CSS曾经在我测试过的所有浏览器中都能使用.它甚至还具有用于处理Firefox的选项选择器.

The following CSS used to work in all browsers that I have tested. It even has an option selector to handle Firefox.

select,
option {
  font-family: "Lucida Console", Monaco, monospace;
}

<select>
  <option>PN-2345&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The first element&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Hardware</option>
  <option>Pn-1332-CFG&nbsp;&nbsp;Second thing&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Powdercoat</option>
</select>

Firefox的最新版本不再正确应用字体系列样式. Firefox的早期版本以及我测试过的所有其他主要浏览器,都将字体系列设置完全应用于选择框和下拉列表中的项目-现在,它仅应用于选择框本身,而不应用于下拉框.

The newest versions of Firefox no longer properly apply font family styles. Former versions of Firefox, and every other major browser I've tested, fully apply the font family settings both to the select and to the items in the dropdown - now, it only gets applied to the select box itself, but NOT the dropdown.

Firefox是否仍支持下拉菜单的字体系列更改?如果可以,怎么办?

Does Firefox still support font-family changes to dropdowns? If so, how?

推荐答案

这项工作有效吗?您可以使用此代码:)

Does this work? You can use this code if you want to :)

var ff = document.getElementById('sel');

function font() {
  ff.style.fontFamily = "'" + ff.value + "', sans-serif";
}

select {
  font-family: 'Overpass', sans-serif;
}

option#diff {
  font-family: 'Ubuntu', sans-serif;
}

option#muli {
  font-family: 'Muli', sans-serif;
}

option#over {
  font-family: 'Overpass', sans-serif;
}

<link href="https://fonts.googleapis.com/css2?family=Muli:wght@300&family=Overpass:wght@300&family=Ubuntu:wght@300&display=swap" rel="stylesheet">
<select id='sel' onchange='font()'>
  <option id='muli' value='Muli'>Muli yay</option>
  <option selected id='over' value='Overpass'>Overpass hooray</option>
  <option id='diff' value='Ubuntu'>Ubuntu is awesome</option>
</select>

这篇关于对&lt; SELECT&gt;的CSS字体家族支持已删除在Firefox中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆