Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Centering element in Div tag

Tags:

html

css

I have a image in div. I want set vertical align bottom and Horizontal Align center for image in div.

to center element i use align but my element set right position.

  <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>

Example : enter image description here

like image 546
Niloo Avatar asked Nov 17 '25 12:11

Niloo


1 Answers

if img tag has not float assigned then simply adding text-align : center to div will solve the problem.

<div style="text-align:center">
    <asp:Image runat="server" ID="Image1" Width="140px" ImageUrl="" />
  </div>

EDIT :

check this demo : demo

like image 165
Behnam Esmaili Avatar answered Nov 20 '25 02:11

Behnam Esmaili