php - How do you center an image in a specified area, without resizing the image? -


I want to center an image without resizing it in any area ... I am using HTML.

Example:

I have an image & lt; Img src = 'img1.png' width = '64 'height =' 64 '& gt; - The image is actually 64x64, it is fully displayed.

Now, I have another image & lt; Img src = 'img2.png' width = '64 'height =' 64 '& gt; However, this is not as big as it should be, its 32x32 - what happens here, it changes the image to 64x64 and it looks like $% ^ & amp;

How do I make the images smaller, then the desired width and height can be centered without any resizing in the 'IMG' area?

What you need is something like this:

  & lt; Div class = "box" & gt; & Lt; Img src = "size of the picture you want" /> & Lt; / Div & gt;  

For more styling (in external stylesheets, nuts) you will apply:

prefix

Solid; Height: 64px; Width: 64px; Background: # 444; Exhibit: Table-Cell; Vertical-row: middle; } .box IMG {display: block; Margin: 0 px auto; }

This works for images with dimensions & lt; = 64x64px, and is easily replaceable to work with big photos

  • Display as a table-cell (allows vertical alignment)
  • Vertical Alignment (aligns
  • Margins: to move images to the letter

  • Comments

    Popular posts from this blog

    c++ - Linux and clipboard -

    What is expire header and how to achive them in ASP.NET and PHP? -

    sql server - How can I determine which of my SQL 2005 statistics are unused? -