对齐 ASP.NET Web 应用程序页面上的控件
我正在尝试在选项卡容器的一个选项卡面板上设置一个带有数据网格和图表的 Web 应用程序。开始一切正常,但我需要将图表放置在数据网格旁边。我读到有关使用 css 但无法让它工作。 我添加了一个单独的 css 文件
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<link type="text/css" rel="stylesheet" href="defaultStyle.css"/>
......
<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateColumns="False" BackColor="White" BorderColor="#336666"
BorderStyle="Double" BorderWidth="3px" CellPadding="4"
DataSourceID="SqlDataSource1" GridLines="Horizontal" Height="92px"
Width="327px" HorizontalAlign="Right">
<RowStyle BackColor="White" ForeColor="#333333" HorizontalAlign="Right" />
<PagerStyle HorizontalAlign="Center" BackColor="#336666" ForeColor="White" />
<Columns>
<asp:BoundField DataField="RecordsCount" HeaderText="RecordsCount"
ReadOnly="True" SortExpression="RecordsCount"/>
<asp:BoundField DataField="collectionDate" HeaderText="collectionDate"
ReadOnly="True" SortExpression="collectionDate" />
</Columns>
<FooterStyle BackColor="White" ForeColor="#333333" />
<SelectedRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" />
</asp:GridView>
I am trying to set up a web application with a datagrid and a chart on one tabpanel of a tabcontainer. It started of ok but I need to have the chart positioned right next to the datagrid. I read about using css but cannot get it to work.
I have added a separate css file
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<link type="text/css" rel="stylesheet" href="defaultStyle.css"/>
....
<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateColumns="False" BackColor="White" BorderColor="#336666"
BorderStyle="Double" BorderWidth="3px" CellPadding="4"
DataSourceID="SqlDataSource1" GridLines="Horizontal" Height="92px"
Width="327px" HorizontalAlign="Right">
<RowStyle BackColor="White" ForeColor="#333333" HorizontalAlign="Right" />
<PagerStyle HorizontalAlign="Center" BackColor="#336666" ForeColor="White" />
<Columns>
<asp:BoundField DataField="RecordsCount" HeaderText="RecordsCount"
ReadOnly="True" SortExpression="RecordsCount"/>
<asp:BoundField DataField="collectionDate" HeaderText="collectionDate"
ReadOnly="True" SortExpression="collectionDate" />
</Columns>
<FooterStyle BackColor="White" ForeColor="#333333" />
<SelectedRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" />
</asp:GridView>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将控件包裹在 div 中并将它们浮动到左侧。完成后请务必清除浮子。
Wrap your controls in divs and float them to the left. Make sure to clear the float when finished.
将每个(网格和图表)包装在其自己的 DIV 元素中。
根据需要使用
top
/left
或float
css 属性设置 DIV 样式。您可能还需要涉及margin
以获得您想要的外观。Wrap each (Grid and Chart) in its own DIV element.
Style DIVs with
top
/left
, orfloat
css attributes as needed. You might also need to getmargin
involved to get the look you want.