由于描述而正在推送布局
我正在使用 DataList 控件水平显示每行三个产品。 但存在布局问题,它推高了产品图像容器元素,如下所示:
数据列表布局问题http://www.pixelshack.us/images/wwmlzkvhxsr7b2l0ptcl.jpg
这是代码:
<asp:DataList ID="dlProducts" runat="server" RepeatColumns="3" RepeatLayout="Table"
DataSourceID="ObjectDataSourceCategories" RepeatDirection="Horizontal" CellSpacing="10" CellPadding="0" HorizontalAlign="Center" ItemStyle-Wrap="true">
<ItemTemplate>
<a href='<%# "Items.aspx?catId=" + (string)Eval("id") %>'>
<asp:Image ID="Image1" CssClass="photo-border photo-float-left" runat="server" Width="165px"
Height="120px" ImageUrl='<%# "ProductImages/Thumbnails/" + (string)Eval("ImageUrl") %>'
AlternateText='<%#(string)Eval("ImageAltText")%>' /></a>
<br />
<asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%# "Items.aspx?catId=" + (string)Eval("id") %>'
Text='<%# Eval("Title").ToString()%>' Font-Bold="true" />
</ItemTemplate>
</asp:DataList>
我怎样才能解决这个问题?
提前致谢。
I am using DataList control to show three products per line horizontally. But there is layout problem and it pushes up the product image container element like the below :
Data List Layout problem http://www.pixelshack.us/images/wwmlzkvhxsr7b2l0ptcl.jpg
Here is the code :
<asp:DataList ID="dlProducts" runat="server" RepeatColumns="3" RepeatLayout="Table"
DataSourceID="ObjectDataSourceCategories" RepeatDirection="Horizontal" CellSpacing="10" CellPadding="0" HorizontalAlign="Center" ItemStyle-Wrap="true">
<ItemTemplate>
<a href='<%# "Items.aspx?catId=" + (string)Eval("id") %>'>
<asp:Image ID="Image1" CssClass="photo-border photo-float-left" runat="server" Width="165px"
Height="120px" ImageUrl='<%# "ProductImages/Thumbnails/" + (string)Eval("ImageUrl") %>'
AlternateText='<%#(string)Eval("ImageAltText")%>' /></a>
<br />
<asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%# "Items.aspx?catId=" + (string)Eval("id") %>'
Text='<%# Eval("Title").ToString()%>' Font-Bold="true" />
</ItemTemplate>
</asp:DataList>
How can I get over the problem ?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也有类似的问题。 我最终不得不将链接的图像和文本分解为自己的 div 并相应地设置它们的样式:
我确信有更简洁的方法可以做到这一点,这只是 HTML 输出可能是什么样子的示例。 这只是“即兴”,但如果您放入空的 htm 文件,它就会显示。
您很可能使用 RepeatLayout="Flow" ItemStyle="float:left;" 在您的 DataList 控件中也能提供帮助。
I was having a similar issue. I ended up having to break the linked image and and text into their own div and style them accordingly:
I'm sure there are cleaner ways to do this and this is just example of what the HTML output might look like. This is just "off the cuff" but if you put in an empty htm file it will display.
You can most likely use RepeatLayout="Flow" ItemStyle="float:left;" in your DataList control to help as well.
我不知道如何解决这个问题,但我首先将每个项目放入
或
中,然后使用 CSS 类,而不是控件的样式。 例如:
将其与 Firebug 一起使用进行调试通常比弄清楚如何违反控件的高度等更容易。
I'm not sure off the top of my head how to fix this, but I would start by putting each item in a
<div>
or<span>
and use CSS classes, instead of the control's styling. E.g.:Using this with Firebug to then debug is usually easier than figuring out how you're violating the control's height, etc.