C# 表格单元格中的居中按钮/文本
我在C# 表格单元格中的居中按钮/文本,c#,html,css,asp.net,C#,Html,Css,Asp.net,我在.aspx文件中有这样一个表 <asp:Table ID="tblRoles" runat="server" GridLines="Both" HorizontalAlign="center" Style="margin-top: 1em; margin-left:1em; margin-right:1em;"> <asp:TableHeaderRow ForeColor="White" BackColor="DodgerBlue" Style="backgrou
.aspx
文件中有这样一个表
<asp:Table ID="tblRoles" runat="server" GridLines="Both" HorizontalAlign="center" Style="margin-top: 1em; margin-left:1em; margin-right:1em;">
<asp:TableHeaderRow ForeColor="White" BackColor="DodgerBlue" Style="background: linear-gradient(to bottom right, #6688FF, #AACCFF); height: 4em; text-align: center; text-transform: capitalize;">
<asp:TableHeaderCell Text="one"/>
<asp:TableHeaderCell Text="two" width="10%"/>
<asp:TableHeaderCell Text="three" width="10%"/>
</asp:TableHeaderRow>
</asp:Table>
表格在页面上的格式很好,但每个单元格内的元素都向左对齐。有没有办法使内容在表格中居中?在CSS中,将
表格td{text align:center;}
添加到表格样式标记中:
<asp:Table ID="tblRoles" runat="server" GridLines="Both" HorizontalAlign="center" Style="margin-top: 1em; margin-left:1em; margin-right:1em; text-align: center;">
或者,如果可能的话,在网站的CSS文件中执行此操作。您可以使用CSS实现此目的。您可以添加到输出的html中吗?
<asp:Table ID="tblRoles" runat="server" GridLines="Both" HorizontalAlign="center" Style="margin-top: 1em; margin-left:1em; margin-right:1em; text-align: center;">