如何更改下拉列表项的字体族? [英] How to change font-family of drop down's list item?

查看:132
本文介绍了如何更改下拉列表项的字体族?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个下拉列表,列出字体系列。像Tahoma,Arial,Verdana等,我想根据它所代表的值来改变每个下拉项目的font-family。就像Photoshop一样。

I have a drop-down that lists font families. Like Tahoma, Arial, Verdana, etc. I want to change the font-family of each drop-down item according to the value it represents. Just like Photoshop does it.

我改变了每个下拉项目的CSS,但它只适用于FireFox。它不能在任何其他浏览器上工作。

I changed the CSS for each drop-down item but it only works on FireFox. It doesn't work on any other browser.

我不想使用任何jQuery插件。

I don't want to use any jQuery plugin.

推荐答案

这是因为 select 元素子元素(选项

That's because the select elements children (options) aren't really stylable and firefox seems to be the only browser to ignore that part of the spec.

解决方法是替换你的 select 元素与一个只使用可定制元素和一个小的javascript的交互性的自定义小部件。像这里做的: http://jsfiddle.net/sidonaldson/jL7uU/ 罢工>或 http://jsfiddle.net/theredhead/4PQzp/

The workaround is to replace your select element with a custom widget that uses only stylable elements and perhaps a little javascript for the interactivity. like what's done here: http://jsfiddle.net/sidonaldson/jL7uU/ or http://jsfiddle.net/theredhead/4PQzp/

这篇关于如何更改下拉列表项的字体族?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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