【问题标题】:Good Practice on adding space between HTML /ASP.NET Control在 HTML /ASP.NET 控件之间添加空格的良好实践
【发布时间】:2012-09-05 07:42:48
【问题描述】:

我现在正在寻找有关如何在 ASP.NET 或 HTML 中的控件之间添加空间的任何方法。目前我在表单上使用了很多 &nbsp 只是为了在我的控件之间添加空间。

例如:

<table>
<tr>
<td>
        <asp:TextBox ID="textbo1" runat="server" Visible="true" Width="50px"></asp:TextBox>
        &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 
</td>

<td>
         <asp:TextBox ID="textbox2" runat="server" Visible="true" Width="50px" ></asp:TextBox>
</td>
</tr>
</table>

是否有这种或其他方式的良好做法。

感谢您的问候

【问题讨论】:

  • ..正确..我还是个新手 :D ...所以我真的需要为此使用 CSS...我需要顺便学习很多东西..: D 有一天或更早我会像你们一样.. :D
  • 我完全理解,只是好奇新手如何使用&amp;nbsp; 来达到此目的。从未遇到过 HTML 之外的不间断空格字符。

标签: asp.net html controls


【解决方案1】:

你为什么不使用名为"Paddding" 的 CssStyle 属性来帮助你

为你的情况使用padding-right

padding-right:10px;

【讨论】:

    【解决方案2】:

    感谢帖子解决了我的问题:

    <table>
    <tr>
    <td>
            <asp:TextBox ID="textbo1" runat="server" Visible="true" Width="50px"></asp:TextBox>
    </td>
    
      <td style="padding-left:110px;"> </td>
    
    <td>
             <asp:TextBox ID="textbox2" runat="server" Visible="true" Width="50px" ></asp:TextBox>
    </td>
    </tr>
    </table>
    

    再次感谢

    【讨论】:

    • 我认为最好接受为您提供有关解决方案的信息的答案,而不是根据给定的答案粘贴您的解决方案并接受它..也赞成为您提供信息的答案...
    【解决方案3】:

    使用 CSS 样式属性 - paddingmargin

    .foo
    {
      padding:10px 3px 4px 10px;
    }
    

    【讨论】:

      【解决方案4】:

      你可以在 TD 上设置一个类

      例如

          <style type="text/css">
      .padl{padding-left:10px}
              </style>
      
      <table>
      <tr>
      <td class="padl">
              <asp:TextBox ID="textbo1" runat="server" Visible="true" Width="50px"></asp:TextBox>
      </td>
      
      <td>
               <asp:TextBox ID="textbox2" runat="server" Visible="true" Width="50px" ></asp:TextBox>
      </td>
      </tr>
      </table>
      

      【讨论】:

        【解决方案5】:

        您必须引入如下所示的样式表,并添加 30px 值以使您满意。样式表最好放在自己的文件中,但也可以放在您的 html 中,如下所示。

        <style type="text/css">
           input.withSpace
           {
               margin-right: 30px;
               margin-bottom: 30px;
           }
        
        </style>
        
        <table>
        <tr>
        <td>
                <asp:TextBox ID="textbo1" cssclass="withSpace" runat="server" Visible="true" Width="50px"></asp:TextBox>
        </td>
        
        <td>
                 <asp:TextBox ID="textbox2" runat="server" Visible="true" Width="50px" ></asp:TextBox>
        </td>
        </tr>
        </table>
        

        【讨论】:

          【解决方案6】:

          在 asp 标签中使用样式并根据需要设置格式

          <table>
          <tr>
          <td>
          <asp:TextBox ID="textbo1" runat="server" Visible="true" Width="50px"style="position:absolute;left:300px" ></asp:TextBox>
          </td>
          <td>
          <asp:TextBox ID="textbox2" runat="server" Visible="true" Width="50px" ></asp:TextBox>
          </td>
          </tr>
          </table>
          

          【讨论】:

            猜你喜欢
            • 2013-01-10
            • 2017-05-07
            • 2015-06-09
            • 2023-03-23
            • 1970-01-01
            • 1970-01-01
            • 2015-03-20
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多