html元素 定位选择

tech2022-12-25  53

html元素 定位选择

描述 (Description)

The select form control is a container for a series of option elements that display in the browser as a pull-down menu (that is, a drop-down list). Unless you use the multiple attribute, the control will allow the user to pick just one item from the list of options that’s generated by the contents of the nested option elements. The select renders slightly differently depending on the browser and operating system in use, and is well known as a troublesome HTML element to style with CSS (because the display is inherited from the operating system, rather than provided by the browser). If there isn’t enough room on the page for the list to display below the control, it will open up above it. The below image shows and expanded select list in Firefox.

选择表单控件是一系列选项元素的容器,这些选项元素在浏览器中显示为下拉菜单(即下拉列表)。 除非您使用Multiple属性,否则控件将允许用户仅从由嵌套选项元素的内容生成的选项列表中选择一项。 select的呈现方式略有不同,具体取决于所使用的浏览器和操作系统,并且众所周知,它是使用CSS设置样式的麻烦HTML元素(因为显示是从操作系统继承的,而不是由浏览器提供的)。 如果页面上没有足够的空间显示在控件下方,则列表将在控件上方打开。 下图显示并扩展了Firefox中的选择列表。

(Example)

This example shows a very simple select element:

此示例显示了一个非常简单的select元素:

<form> <label for="favoritefood">Favorite food</label> <select name="favoritefood" id="favoritefood"> <option>Cheese</option> <option>Egg</option> <option>Cabbage</option> ⋮ </select> </form>

将此用于… (Use This For…)

This element is used to allow visitors to make selections from a long list of items. The alternative approach would involve the use of radio input selections, but this would require all the options to be displayed on the page at once; select controls generally display in a smaller amount of page real estate.

此元素用于允许访问者从一长串物品中进行选择。 另一种方法是使用无线电输入选择,但这将要求所有选项立即显示在页面上。 选择控件通常以较小的页面空间显示。

翻译自: https://www.sitepoint.com/select-html-element/

html元素 定位选择

最新回复(0)