- 表单控制分组 - html5 表单
fieldset 元素通常用来对表单中的控制元素进行分组(也包括 label 元素)
浏览器支持
所有主流浏览器都支持 标签。 |
示例
一个拥有,
和
的表单
title click me
标签定义及使用说明
标签可以将表单内的相关元素分组。
标签将表单内容的一部分打包,生成一组相关表单的字段。
- 当一组表单元素放到
标签内时,浏览器会以特殊方式来显示它们,它们可能有特殊的边界、3D 效果,或者甚至可创建一个子表单来处理这些元素。
标签会在相关表单元素周围绘制边框。
标签为
元素定义标题。
标签没有必需的或唯一的属性。
Content categories | 流式内容元素,sectioning root,listed,form-associatedelement,段落内容元素. |
---|---|
Permitted content | An optional element, followed by flow content. |
Tag omission | 不允许,开始标签和结束标签都不能省略。 |
允许的父元素 | 可接受的任何元素flow content. |
DOM接口 | HTMLFieldSetElement |
注意:与几乎任何其他元素不同,WHATWG HTML Rendering规范建议
作为min-width
:min-content
默认样式的一部分,并且许多浏览器都实现了这种样式(或者与其类似的东西).
属性
属性 | 值 | 描述 |
---|---|---|
disabled HTML5新增 | disabled | 规定该组中的相关表单元素应该被禁用。 |
form HTML5新增 | form_id | 规定 fieldset 所属的一个或多个表单。 |
name HTML5新增 | text | 规定 fieldset 的名称。 |
HTML 4.01 与 HTML 5 之间的差异
HTML5 中新增了一些的新属性:disabled、form、name,HTML 4.01 中不支持这些属性。
全局属性
标签支持HTML的全局属性。
事件属性
标签支持HTML的事件属性。
实例
对表单中的相关元素进行分组:
personalia: name:
email:
date of birth:
利用包含radioboxesandtextboxes的 fieldset 模拟一个可编辑的元素。下面的例子只使用了 HTML 和 CSS.
请注意,屏幕朗读和辅助设备不能正确的解析下面的表单,如果不使用正确的元素这个例子是不适合在生产环境中使用.
editable [pseudo]select /* generic form fields */ fieldset.elist, input[type="text"], textarea, select, option, fieldset.elist ul, fieldset.elist > legend, fieldset.elist input[type="text"], fieldset.elist > legend:after { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } input[type="text"] { padding: 0 20px; } textarea { width: 500px; height: 200px; padding: 20px; } textarea, input[type="text"], fieldset.elist ul, select, fieldset.elist > legend { border: 2px #cccccc solid; border-radius: 10px; } input[type="text"], fieldset.elist, select, fieldset.elist > legend { height: 32px; font-family: tahoma; font-size: 14px; } input[type="text"]:hover, textarea:hover, select:hover, fieldset.elist:hover > legend { background-color: #ddddff; } select { padding: 4px 20px; } option { height: 30px; padding: 5px 4px; } option:not(:checked), textarea:focus { background-color: #ffcccc; } fieldset.elist > legend:after, fieldset.elist label { height: 28px; } input[type="text"], fieldset.elist { width: 316px; } input[type="text"]:focus { background: #ffcccc url("data:image/gif;base64,r0lgodlheaaqanu5apnoxuvr6+uxpdvb2+rq6ri4uo7qxunp6dpt06shv+/rx8vly+nezlo0sbe3t9ksas+qaacev8rkyp2dnf39/qaaak6ursifzhfxcc/qzu3mxyymjexcjnv1dc6mao7u7o+pj2txnoaghtfdpkcdvu3lxm+tcakev9bw1qofvwnjy8kristexnra2nbbobgxsby8vo/mu7kyso9zauzs7msgaiikhf///8zmzp///waaaaaaaaaaaaaaaaaaaaaaach5baeaadkalaaaaaaqabaaaaaxwjxwscwoyzwkmpkkzmoaqdqajdpqaqw2m53nrjlboaarfczomce0c99o8dgnmvm8tm3bbydr9x11dwkzdg5yc2oqjircenx/mxoeetm2q3pxatmlf4mylo17oasdlispmyaioiy0bzmcitmtkbasjgssftmqgxitmjyuotqbbaqhxge0wzcfmtdrmi/qra022nnang1cqqa7") no-repeat 2px center !important; } input[type="text"]:focus, textarea:focus, select:focus, fieldset.elist > legend { border: 2px #ccaaaa solid; } fieldset { border: 2px #af3333 solid; border-radius: 10px; } /* editable [pseudo]select (i.e. fieldsets with [class=elist]) */ fieldset.elist { display: inline-block; position: relative; vertical-align: middle; overflow: visible; padding: 0; margin: 0; border: none; } fieldset.elist ul { position: absolute; width: 100%; max-height: 320px; padding: 0; margin: 0; overflow: hidden; background-color: transparent; } fieldset.elist:hover ul { background-color: #ffffff; border: 2px #af3333 solid; left: 2px; overflow: auto; } fieldset.elist ul > li { list-style-type: none; background-color: transparent; } fieldset.elist label { display: none; width: 100%; } fieldset.elist input[type="text"] { width: 100%; height: 30px; line-height: 30px; border: none; background-color: transparent; border-radius: 0; } fieldset.elist > legend { display: block; margin: 0; padding: 0 0 0 5px; position: absolute; width: 100%; cursor: default; background-color: #ccffcc; line-height: 30px; font-style: italic; } fieldset.elist:hover > legend { position: relative; overflow: hidden; } fieldset.elist > legend:after { width: 20px; content: "2335"; float: right; text-align: center; border-left: 2px #cccccc solid; font-style: normal; cursor: default; } fieldset.elist:hover > legend:after { background-color: #99ff99; } fieldset.elist ul input[type="radio"] { display: none; } fieldset.elist input[type="radio"]:checked ~ label { display: block; width: 292px; background-color: #ffffff; } fieldset.elist:hover input[type="radio"]:checked ~ label { width: 100%; } fieldset.elist:hover label { display: block; height: 100%; } fieldset.elist label:hover { background-color: #3333ff !important; } fieldset.elist:hover input[type="radio"]:checked ~ label { background-color: #aaaaaa; } order a t-shirtwrite your name (simple textbox):
choose your size (simple select): small medium large extra large
what address do you want to use? (editable pseudoselect) address…
write a comment:
鹏仔微信 15129739599 鹏仔QQ344225443 鹏仔前端 pjxi.com 共享博客 sharedbk.com
图片声明:本站部分配图来自网络。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!