可能的重复:
是否可以设置选择框的样式?
我是寻找一种在我的 HTML 代码中自定义选择元素的方法。
我希望我的选择看起来像这样:
我希望用户能够看到一个图像和两个文本,它代表我的列表的第一个元素。由于这应该通过智能手机(Android 和 Blackberry)访问,我相信该列表将在操作系统组件中打开,因此我不必费心设计我选择的其余选项,对吧?
实现这一目标的最佳方法是什么?
预先非常感谢!
Possible Duplicate:
Is it possible to style a select box?
I'm searching for a way to customize a select element in my HTML code.
I wanted my select to look like this:
I want the user to be able to see an image and two texts, which represents the first element of my list. Since this is supposed to be accessed by a smartphone (Android and Blackberry), I believe the list will open in the operating system component, so I don't have to bother styling the remaining options of my select, right?
What is the best way to accomplish this?
Thanks a lot in advance!
发布评论
评论(6)
我认为仅通过 css 样式化
我建议使用其他元素,例如
来完成你想要的,以及一点 javascript (jQuery, MooTools)以获得附加效果。
I don't think you can accomplish quite as much as you want with just css styling a
<select>
tag. This is about how far it goes: http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/I would suggest using other elements, like
<div>
s to accomplish what you want, and a little bit of javascript (jQuery, MooTools) for the added effects.看来您需要一个 JavaScript 图像组合框。这篇文章非常简单,我相信您可以比文章中所写的内容进一步定制它。试一试吧! :-)
It seems like you need a JavaScript image combobox. The article is pretty straightforward, and i believe you can customize it even further than whats written in the article. Give it a shot! :-)
我使用jQuery插件prettySelectBox,推荐它。 http://abeautifulsite.net/blog/2011/01/jquery-selectbox-插件/
I use jQuery plugin prettySelectBox, recommend it. http://abeautifulsite.net/blog/2011/01/jquery-selectbox-plugin/
样式选择是出了名的困难 - 浏览器供应商不允许在表单元素上广泛使用自定义样式。
解决这个问题的一种方法是使用 javascript,也许使用 jQuery 等库。
此页面上有一些很好的答案和插件链接:
是否可以设置选择框的样式?
Styling selects is notoriously difficult - browser vendors have not allowed for widespread custom styling on form elements.
One way to get around it is to use javascript, maybe with a library such as jQuery.
There's some good answers and links to plugins on this page:
Is it possible to style a select box?
HTML
标签、
HTML
<select>
tag is part of a larger set, called HTML form controls. They are different types of<input>
tag,<select>
tag,<textarea>
. The most common known issues of HTML form elements (controls) is that, they don't have cross-browser look & feel. In other words, while a browser may animate a drop-down menu (a select element), another browser may open it up abruptly and at-once. Thus, a known web-design and development practice, is to create your custom controls, from scratch using simple elements and JavaScript (usually jQuery). Thus, I recommend that you create it on your own, instead of trying to find out how to make what you want (and to be honest, I think what you're looking for is not possible, since nesting block-level elements inside<option>
tags are not allowed, if you want to have valid HTML).选择的元素是那些接受较少定制的元素,因此您设计它们的自由度非常有限。
为了实现您想要的目标,我建议您使用自定义 HTML、JavaScript 和 CSS 构建自己的类似选择的组件。
如果您想使用已有的链接,我建议您查看以下链接:
但是,因为你正在寻找什么因为太具体了,您可能需要自己创建下拉菜单。
Select elements are the ones which less customization acepts, so your freedom to style them is very limited.
In order to achive what you are looking for, I suggest you to build your own select-like component using custom HTML, JavaScript and CSS.
If you want to use an already existing one, I suggest you to take a look at the following links:
However, since what you are looking for is too specific, probably you will need to create your dropdown in your own.