我正在使用ASP.NET 3.0+,并有一个表格如下:
<asp:Table ID="metadataTable" runat="server" BorderWidth="0" CellSpacing="5">
<asp:TableRow>
<asp:TableCell BorderWidth="3" ID="tcProperties1" ><asp:PlaceHolder ID="Properties1" runat="server"></asp:PlaceHolder></asp:TableCell>
<asp:TableCell BorderWidth="3" ID="tcProperties2" ><asp:PlaceHolder ID="Properties2" runat="server"></asp:PlaceHolder></asp:TableCell>
<asp:TableCell BorderWidth="3" ID="tcProperties3" ><asp:PlaceHolder ID="Properties3" runat="server"></asp:PlaceHolder></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell BorderWidth="3" ID="tcTree1" VerticalAlign="Top"><asp:PlaceHolder ID="Tree1" runat="server"></asp:PlaceHolder></asp:TableCell>
<asp:TableCell BorderWidth="3" ID="tcTree2" VerticalAlign="Top"><asp:PlaceHolder ID="Tree2" runat="server"></asp:PlaceHolder></asp:TableCell>
<asp:TableCell BorderWidth="3" ID="tcTree3" VerticalAlign="Top"><asp:PlaceHolder ID="Tree3" runat="server"></asp:PlaceHolder></asp:TableCell>
</asp:TableRow>
</asp:Table>
问题是占位符有时是故意空的。为此我打电话:
tcProperties2.Visible = false;
tcTree1.Visible = false;
tcTree3.Visible = false;
并且细胞向左移动。即我想要的时候:
[Cell 0,0] [Cell 2,0]
[Cell 1,1]
其中单元格0,1 1,0和2,1没有控件,我得到以下内容:
[Cell 0,0] [Cell 2,0]
[Cell 1,1]
有没有办法让他们在不使用明显的&nbsp hack的情况下保持间隔?
答案 0 :(得分:1)
将以下CSS添加到您的代码中,方法是将其包含在外部/嵌入式CSS样式表中,或者添加内联样式:
table {
empty-cells: show;
}