【发布时间】:2013-07-21 11:22:50
【问题描述】:
我有一个页面,它附有那个图像。 在我的 css 中,我将宽度和高度配置为自动显示表格! 但是在某些列中,例如,不会在在线行中显示所有信息。 如何配置我的 Grid 以在一行中显示所有行?
我的aspx:
<body>
<form id="form1" runat="server">
<div>
<div style="width: auto; height: auto;" align="center">
<img src="image/NdriveBanner.png" align="center" />
</div>
<br />
<br />
<div id="Div1" runat="server">
<asp:Label Font-Bold="true" runat="server" Font-Size="X-Large">Here are your tickets!</asp:Label>
<br />
<br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" GridLines="None"
CssClass="table table-bordered table-striped">
<Columns>
<asp:BoundField DataField="UserName" HeaderText="User" />
<asp:BoundField DataField="AccessGroup" HeaderText="Access Group" />
<asp:BoundField DataField="FolderAccess" HeaderText="Folder Access" />
<asp:BoundField DataField="RequestDate" HeaderText="Request Date" DataFormatString="{0:d}" />
<asp:BoundField DataField="SituationDesc" HeaderText="Situation" />
<asp:BoundField DataField="Approver" HeaderText="Approver" />
<asp:BoundField DataField="ApprovalDate" HeaderText="Approval Date" DataFormatString="{0:d}" />
<asp:BoundField DataField="BusinessJustification" HeaderText="Business Justification" />
<asp:BoundField DataField="Server" HeaderText="Server Name" />
<asp:BoundField DataField="UserRequestor" HeaderText="User Request" />
<asp:TemplateField Visible="false">
<ItemTemplate>
<asp:HiddenField ID="Access" runat="server" Value='<%# Bind("Access") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<br />
<br />
<div align="center" style="width: auto; height: auto;">
<asp:HyperLink ID="HyperLink2" runat="server" ImageUrl="~/image/home_back_48.png"
NavigateUrl="~/home.aspx">homepage</asp:HyperLink>
</div>
</div>
</form>
我的 .css
table
{
max-width:none;
background-color:transparent;
border-collapse:collapse;
border-spacing:0;
}
.table
{
width:auto;
height:auto;
margin-bottom:20px;
}
.table th,.table td
{
width:auto;
height:auto;
padding:8px;
line-height:20px;
text-align:left;
vertical-align:top;
border-top:1px solid #dddddd;
}
.table th
{
width:auto;
height:auto;
font-weight:bold;
}
.table thead th
{
vertical-align:bottom;
}
【问题讨论】:
-
这与 CSS 无关。这是表格单元格中内容量的问题。可能的解决方案是:单元格内容更少,字体更小,单元格宽度更大。
-
空间不足,无法在一行中显示所有内容。水平滚动可能会有所帮助,但水平滚动有点奇怪。通常,我们会显示几列并添加展开/折叠按钮以获取详细信息。
-
但是如果我将宽度设置为自动,即使有很多信息,所有单元格也不应该显示在一行中?我有其他网格,它使用其他 CSS(Telerik 的 Css),并在一行中显示所有信息。但是我不能在同一个页面中使用这个 CSS!
-
@Win 如果我使用水平滚动,如何构建它?