Jump to content

Vertical Align Images?


kensbeijing

Recommended Posts

Well, vertical-align: middle does usually work. The other way is to give your image display: block and use margin: auto 0; That ought to work. Or give it a line height equal to the height of the div.

Link to comment
Share on other sites

First, you need to apply vertical-align to the image, not the container. After that, you have to make the line-height of the container equal to its height.This only works for text and images that stay on one line. If there's a line break, it will all get sent below the <div>.If you want some multiline text to be vertically aligned like in a table cell, you'll need two containers that work like this:http://dtfox-tests.totalh.com/valign.html

Link to comment
Share on other sites

First, you need to apply vertical-align to the image, not the container. After that, you have to make the line-height of the container equal to its height.This only works for text and images that stay on one line. If there's a line break, it will all get sent below the <div>.If you want some multiline text to be vertically aligned like in a table cell, you'll need two containers that work like this:http://dtfox-tests.totalh.com/valign.html
Still doesn't work, does the container have to have a special display:block or something. At the moment the container is floating left.
Link to comment
Share on other sites

it seems to work in IE7, but firefox, displays it at the top, unless text is include with image.however using   with span, and making container slightly larger i managed to get it to work<div style="width: 442px; height: 440px; line-height: 440px; text-align:center; border: 1px solid #000;"><span style="font-size:0px;"> <img src="1cha_imgash_thumb.gif" height="300" width="440" alt=" " style="vertical-align:middle;" /></span></div>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...