在 HTML / ASP.NET 控件之间添加空格的良好做法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12276736/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 02:40:00  来源:igfitidea点击:

Good Practice on adding space between HTML /ASP.NET Control

asp.nethtmlcontrols

提问by BizApps

I am now looking for any way on how to add space between controls in ASP.NET or HTML. Currently i am using A lot of &nbspon my form just to add space between my controls.

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

For example:

例如:

<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>

Is there good practice for this or other way to do it.

有没有好的做法可以做到这一点或其他方式。

Thanks in Regards

致谢

回答by Pranay Rana

Why dont you make use of CssStyle property called "Paddding"that will help you

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

for you case make use of padding-right

对于你的情况,请使用 padding-right

padding-right:10px;

回答by BizApps

Thanks for the posts i solve my problem:

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

<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>

Thanks again

再次感谢

回答by adatapost

Use CSSstyle attribues - paddingand margin.

使用CSS样式属性 -paddingmargin.

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

回答by Pankaj Agarwal

You can do using set an class on TD

您可以在 TD 上使用 set an class

for ex.

例如。

    <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>

回答by mortb

You'll have to introduce a stylesheet like below adn tweek the 30px values to your satisfaction. The stylesheet is best put in a file of its own but may be in lined in your html as below.

你必须引入一个像下面这样的样式表,然后将 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>

回答by Surya Subramanian

use style inside asp tag and format as you need

根据需要使用 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>