2012-09-05 34 views
3

我現在正在尋找任何有關如何在ASP.NET或HTML中的控件之間添加空間的方法。目前我在我的表單上使用了很多&只是爲了在我的控件之間添加空格。在HTML/ASP.NET控件之間添加空間的好習慣

例如:

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

是否有這種或其他方式來做到這一點很好的做法。

謝謝問候

+1

..Correct ..我仍然是一個新手:D ...所以我真的需要使用CSS ... ...我需要學習很多事情的方式..:D有一天或更早,我會像你們一樣.. :D – BizApps

+0

我完全理解,只是好奇新手如何使用' '來達到這個目的。從來沒有遇到HTML以外的非破壞性空間字符。 – tpower

回答

4

你爲什麼不利用CssStyle財產稱爲"Paddding",這將有助於你

你的情況下利用padding-right

padding-right:10px; 
1

使用CSS樣式 attribues - paddingmargin

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

你可以使用下列方法設置類的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> 
0

你必須引入一個像下面的樣式表和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> 
2

感謝您的帖子中,我解決我的問題:ASP標籤和格式內

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

再次感謝

+1

我認爲它更好地接受答案,它給你關於解決方案的信息,而不是根據給定的答案來設置你的解決方案,並接受它。也提供給你信息的答案... –

0

使用的風格,因爲你需要

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