我想知道是否有 <form>
可以包含很多 <fieldset>
在里面?还是用<div>
更好反而?就我而言,我想设计一个复杂的响应式设计 <form>
有许多不同种类的<input>.' And if so, do the
should be in his own
`一个人?
最好是这样:
<form action="#" method="POST">
<fieldset id="input1-wrapper">
<h3>Input 1</h3>
<input type="texte" name="input1" placeholder="input1">
</fieldset>
<fieldset id="input2-wrapper">
<h3>Input 2</h3>
<input type="texte" name="input2" placeholder="input2">
</fieldset>
</form>
或者像这样:
<form action="#" method="POST">
<div id="input1-wrapper">
<h3>Input 1</h3>
<input type="texte" name="input1" placeholder="input1">
</div>
<div id="input2-wrapper">
<h3>Input 2</h3>
<input type="texte" name="input2" placeholder="input2">
</div>
</form>
最佳答案
一个表单中允许有多个字段集。示例:一个 fieldset
中的数据输入字段和 action buttons
(“提交”、“取消”等)在一个单独的字段集中。
字段集应该总是有一个 图例根据标准进行标记。
其实,Fieldsets
只是另一个“显示”块级元素。即把它想象成一个“花哨的 div”。它可以在“块级元素”可以使用的任何地方使用。它对里面的东西没有“特殊知识”。由于“legend”是一个单独的元素,它可以使用 CSS 单独设置样式。
迂腐;-/
www.whatwg.org/specs/web-apps/current-work/multipage/forms
提取的文本:' ...,可以使用 fieldset 元素。这样一组控件的标题由字段集中的第一个元素给出,该元素必须是图例元素。'。
在我看来,带有标题的“div”看起来要好得多。以至于我在表单之外使用它来对事物进行分组。尝试使用 CSS 在边框中获取该文本。
<form action="#" method="POST">
<fieldset id="input1-wrapper">
<legend>Input 1</legend>
<input type="text" name="input1" placeholder="input1">
</fieldset>
<fieldset id="input2-wrapper">
<legend>Input 2</legend>
<input type="text" name="input2" placeholder="input2">
</fieldset>
</form>
关于forms - 表单标签中的多个字段集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22732248/