2012-11-24 146 views
0

我在面板中有一个div。我为此添加一个图像。将图像对齐到底部div

我希望将图像对齐到DIV容器的底部。(显示图象的线。)

<asp:Repeater ID="product" runat="server"> 
    <ItemTemplate> 
     <div style="float: right; width: 180px; height: 177px; margin: 0 30PX 10px 5px"> 
     <asp:Panel ID="Panel1" runat="server"> 
      <font color="white"> 
      <asp:Label ID="Label1" runat="server" Text='<%# Eval("Name") %>'></asp:Label></font> 
      <br /> 
      <div style="height:140px ; overflow:hidden"> 
       <asp:Image ID="Image1" runat="server" Width="120px" ImageUrl='<%# Eval("Image") %>' ImageAlign="Bottom" /> 
      </div> 
     </asp:Panel> 
    </div> 
    </ItemTemplate> 

+0

请清除您的需求ü要低于股利或内部设置图像div的底部 – Milind

+0

我想设置图像底部的div。 – Niloo

+0

?字体元素已被弃用... HTML5中不支持。使用CSS! – MikeSmithDev

回答

1

不要依赖于ASP ImageAlign财产。使用CSS,如:

<div style="float: right; width: 180px; height: 177px; margin: 0 30px 10px 5px; position:relative"> 
    <div id="panel" 
     <label>Name</label> 
     <img id="Image1" src='img-url-goes-here' style="position:absolute;bottom:0px;height:40px;display:block;" /> 
    </div> 
</div>​ 

在你的代码,这将是:

<div style="float: right; width: 180px; height: 177px; margin: 0 30px 10px 5px;"> 
    <asp:Panel ID="Panel1" runat="server"> 
     <font color="white"> 
      <asp:Label ID="Label1" runat="server" Text='<%# Eval("Name") %>'></asp:Label>  
     </font> 
     <div style="overflow:hidden;height:140px; position:relative;"> 
      <asp:Image ID="Image1" runat="server" Width="120px" ImageUrl='<%# Eval("Image") %>' style="position:absolute; bottom:0px; height:40px; display:block;" /> 
     </div> 
    </asp:Panel> 
</div> 
+0

谢谢,我用这个,但不显示图像底部的div。它显示顶部的分区:( – Niloo

+0

@NilooRg的权利,对不起。编辑的答案与工作代码。 –

+0

谢谢,但id on't设置图像的高度...我使用此代码,但我的图像设置的主div和显示botton – Niloo

0

使用vertical-align:bottom在图像DIV

<asp:Repeater ID="product" runat="server"> 
     <ItemTemplate> 
      <div style="float: right; width: 180px; height: 177px; margin: 0 30PX 10px 5px"> 
      <asp:Panel ID="Panel1" runat="server"> 
       <font color="white"> 
       <asp:Label ID="Label1" runat="server" Text='<%# Eval("Name") %>'></asp:Label></font> 
       <br /> 
       <div style="height:140px ; overflow:hidden; vertical-align:bottom"> 
        <asp:Image ID="Image1" runat="server" Width="120px" ImageUrl='<%# Eval("Image") %>' ImageAlign="Bottom" /> 
       </div> 
      </asp:Panel> 
     </div> 
     </ItemTemplate> 
    </asp:Repeater>