简体   繁体   English

如何在CSS中创建没有图像的自定义选项菜单样式?

[英]How to make a custom select option menu style without image in CSS?

[I don't want the Unicode character] [我不想要Unicode字符]
For example: With using Black down-pointing triangle. 例如:使用黑色向下三角形。
It'll using -webkit-appearance: none; 它将使用-webkit-appearance: none; to make it look better. 让它看起来更好。

It would be simple as: 它很简单:
Select ▼
to
Select ▼
Value1
Value2
or something similar 或类似的东西

HTML: HTML:

<select>
  <option>Value1</option>
  <option>Value2</option>
</select>

QUESTION: How to do it in pure CSS, without any JavaScript? 问题:如何在纯CSS中完成,没有任何JavaScript?

Select boxes are not really styleable, so I wouldn't be surprised if this was impossible. 选择框不是真正的风格,所以如果这是不可能的,我不会感到惊讶。 Some limited styling options are available, but even they are unreliable. 有一些有限的造型选择,但即使它们不可靠。 The only way to effectively style a select box is via jQuery and, unfortunately, images. 有效地设置选择框的唯一方法是通过jQuery,不幸的是,图像。 My favourite form styling plugin is this Uniform - maybe it's worth to have a look at it. 我最喜欢的造型插件就是这款Uniform - 也许值得一看。

I came up with this pure HTML, hacky solution, but it sucks. 我提出了这个纯HTML,hacky解决方案,但它很糟糕。 The arrow catches mouse events before they reach the select box. 箭头在到达选择框之前捕获鼠标事件。 You'd need to do some hacking to eliminate that. 你需要做一些黑客来消除它。

您可以在这里看到仅限css的解决方案,仅适用于webkit

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM