0

i have a variable which is an image

$image = "<img src='$imagelocation' width='50px' height='50px'>";

i want it to be in the center of the td but it doesn't center vertically, it stays at the top, i did this

echo "<td valign='middle'><div class='rollover' align='center'>

<a href=\"imageview.php?id=$number\" onmouseover=\"ChgText($keyword)\">$image</a>  

</div>
</td>";

any ideas?

3
Contributors
10
Replies
12
Views
7 Years
Discussion Span
Last Post by SKANK!!!!!
0

The "valign" property does not propagate from the parent to its children children!

Try testing that scenario of yours with static HTML first.
This way you can see where lies the problem.

But from where we are the problem is: the image nested in the div element.
The td valign is pointing to the div element not to the image, so the image will not be valigned because the hosting div is not required to do that with its own children too.

But in any case, the DIVs can't make your inline elements to render vertically aligned in the middle.

Also if you ask me, that DIV is not required and shouldn't be there at first place at all. Remove the div and asign its class to your image instead. >>Keep your HTML code clean.

0

he needs to vertically align in the middle,
as I already mentioned with his actual code structure and his existing styles it can be fixed by simply removing the DIV wrapping his Image in TD elements, nothing else.
But, new comers never bother to come back and tell if some advice helped solve their problem or god forbid mark the thread solved.

0

no he probably has something else in the divs. just td middle align will center the div in side the table td but then u have to go ahead and also center the stuff inside tthe div. simple. then its centered.

0

im sorry did i forget to mention the div should be the size as the image in height? then its vertically centered hon

0

yes i have done it. u verticle center the td. then u add the div and center it in the td. then i make sure that the div is the height of the image inside it and then u make the td the height of the page. ive done it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.