在 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
Good Practice on adding space between HTML /ASP.NET Control
提问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  on 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>
               
</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 - padding
and margin
.
使用CSS样式属性 -padding
和margin
.
.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>