选择列表中的样式选项元素(添加填充和/或边距)

发布于 2024-09-03 18:43:20 字数 90 浏览 0 评论 0原文

是否可以将选择列表/下拉列表的 option 元素设置为背景和字体之外的样式?我特别希望添加一些填充/边距,这样列表就不会那么拥挤。

Is it possible to style the option elements of a select list/dropdown beyond background and font? I'm specifically looking to add some padding/margins so the list isn't as cramped.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我三岁 2024-09-10 18:43:20

如果您想要广泛的浏览器支持,则不可能。至少IE不支持。那么除了使用

  • 和 JavaScript 的良好镜头来模仿并逐步增强下拉列表之外,别无选择。您可以在这里获取 JS 的一些想法(jQuery 实际上)基于下拉菜单。

Not possible if you want broad browser support. At least IE doesn't support it. There's then no other option than to mimic and progressively enhance the dropdown with <ul><li> and a good shot of JavaScript. You can get here some ideas what's possible with JS (jQuery actually) based dropdowns.

暮凉 2024-09-10 18:43:20

@Alex:我们和你一样陷入了同样的困境。我们也想控制下拉菜单的用户界面。不幸的是,正如其他人已经提到的,如果您还想具有跨浏览器兼容性,则您无法选择系统下拉菜单。

所以我们想出了我们自己的 jQuery 插件,它的工作方式就像大多数功能的系统下拉菜单。它还支持主题以及通过模板提供自定义列表项的灵活性。您可以从以下列出的 URL 中查看正在运行的代码示例并了解更多信息。我们确信您会发现它很有用。

  1. 示例和文档 - india.assigninfo.com/assignlabs/jaldropdown
  2. 来自 coderun 的级联下拉示例代码。 com - coderun.com/ide/?w=GEXVey_kckKrAkLeoIfZNg
  3. 从可滚动 DIV 中配置 jaldropdown 的示例代码 - coderun.com/ide/?w=BiE5TbXdIEehDOxNk1oajw

@Alex: we were in the same predicament as you seem to be. We too wanted to control the UI of the dropdown. Unfortunately as others have already mentioned, you have no option with the system dropdown if you want to have cross-browser compatibility also.

so we came up with our own jQuery plugin which works like a system dropdown for most features. It also supports themeing as well as flexibility to provide customized list items by way of templates. You can see the running code samples from the following URLs listed and learn more about it. We are sure you will find it useful.

  1. Sample and documentation - india.assigninfo.com/assignlabs/jaldropdown
  2. Cascading dropdown sample code from coderun.com - coderun.com/ide/?w=GEXVey_kckKrAkLeoIfZNg
  3. Sample code to configure jaldropdown from within scrollable DIVs - coderun.com/ide/?w=BiE5TbXdIEehDOxNk1oajw
悸初 2024-09-10 18:43:20

有可能,但该功能在 Internet Explorer 中不可用

It is possible however the functionality is not available in Internet Explorer

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文