ASP.NET GroupBox看起来像使用带有引导程序的fieldset

时间:2015-09-13 00:47:07

标签: html css asp.net twitter-bootstrap

我正在使用带有表格的模态弹出窗口。我想使用fieldset对一些员工信息进行分组,但问题字段集和表行分为两部分。

<fieldset class="box-border">
    <legend class="box-border">Basic information</legend>
    <tr>
        <td>
            <asp:label id="plEmpCode" runat="server" CssClass="label" Text="Employee ID (*)"></asp:label>
        </td>
        <td>
            <asp:TextBox ID="txtEmpCode" CssClass="textnumber" runat="server"></asp:TextBox>
            <asp:RequiredFieldValidator ID="valEmpCode" runat="server" ControlToValidate="txtEmpCode" ErrorMessage="Enter Employee ID" Display="None"></asp:RequiredFieldValidator>
            <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender1" runat="server" CssClass="customCalloutStyle" TargetControlID="valEmpCode"></asp:ValidatorCalloutExtender>
        </td>
        <td>
            <asp:label id="plEnrollNumber" runat="server" CssClass="label" Text="Enroll Number (*)"></asp:label>
        </td>
    ..........
</fieldset>

引导程序中的CSS:

fieldset.box-border 
{
    border: 1px groove #ddd !important;
    padding: 0 1.4em 1.4em 1.4em !important;
    margin: 0 0 0 0 !important;
    -webkit-box-shadow:  0px 0px 0px 0px #000;
            box-shadow:  0px 0px 0px 0px #000;
}

legend.box-border {
    width:auto; /* Or auto */
    padding:0 10px; /* To give a bit of padding on the left and right */
    border-bottom:none;

    font-size: 12px !important;
    font-weight: bold !important;
    text-align: left !important;

}

这是结果: enter image description here

检查HTML元素结果: enter image description here

1 个答案:

答案 0 :(得分:1)

并将HTML的结构更改为:

...
<tr>
  <td>
    <fieldset class="box-border">
      <legend class="box-border">Basic information</legend>
      <table>
        <tr>
          <td>
            <asp:label id="plEmpCode" runat="server" CssClass="label" Text="Employee ID (*)"></asp:label>
          </td>
          <td>
            <asp:TextBox ID="txtEmpCode" CssClass="textnumber" runat="server"></asp:TextBox>
            <asp:RequiredFieldValidator ID="valEmpCode" runat="server" ControlToValidate="txtEmpCode" ErrorMessage="Enter Employee ID" Display="None"></asp:RequiredFieldValidator>
            <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender1" runat="server" CssClass="customCalloutStyle" TargetControlID="valEmpCode"></asp:ValidatorCalloutExtender>
          </td>
          <td>
            <asp:label id="plEnrollNumber" runat="server" CssClass="label" Text="Enroll Number (*)"></asp:label>
          </td>
          ..........
        </tr>
      </table>
    </fieldset>
  </td>
</tr>
...

可以解决......