【问题标题】:Multiple fieldset in a form tag表单标签中的多个字段集
【发布时间】:2014-03-29 14:19:09
【问题描述】:

我想知道<form> 中是否可以包含多个<fieldset>?还是改用<div> 更好?就我而言,我想设计一个复杂的响应式设计<form>,仅包含许多不同类型的<input>.' And if so, do theshould 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>

【问题讨论】:

    标签: forms input fieldset


    【解决方案1】:

    一个表单中允许有多个字段集。示例:fieldsetaction buttons(“提交”、“取消”等)中的数据输入字段位于单独的字段集中。

    根据标准,字段集应始终具有 legend 标记。

    实际上,Fieldsets 只是另一个“显示”块级元素。即认为它是一个“花式div”。它可以在任何“块级元素”可以使用的地方使用。它对里面的东西没有“特殊知识”。由于“图例”是一个单独的元素,它可以使用 CSS 单独设置样式。

    学究气 ;-/

    www.whatwg.org/specs/web-apps/current-work/multipage/forms

    提取的文本:' ...,可以使用字段集元素。这样一组控件的标题由字段集中的第一个元素给出,它必须是一个图例元素。'。

    在我看来,带标题的“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>
    

    【讨论】:

    • @Floradu88,感谢您的更正-如果我是“迂腐”和“正确”,那就太好了! :-)
    猜你喜欢
    • 2014-06-25
    • 2012-09-10
    • 1970-01-01
    • 2022-12-17
    • 2016-12-08
    • 2012-08-17
    • 1970-01-01
    • 2012-08-12
    • 1970-01-01
    相关资源
    最近更新 更多