Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

HTML table vertical aligning problem

HTML

  • This topic is locked This topic is locked
2 replies to this topic

#1 Carrym

Carrym

    CC Lurker

  • Just Joined
  • Pip
  • 3 posts

Posted 21 March 2007 - 05:55 AM

When posting code please use code tags. There are PHP, HTML and CODE tags that can be used while posting code segments.

Hey,
I am trying to get the text in the second cell of this HTML table to be centered vertically in the middle of the the image in the first cell. See the code. For some reason the text is always positioned at the bottom of the cell! Sorry for all the encrypted stuff, but this is how I can replicate this problem. Basically I want the text 'Sample Text' to be properly vertically aligned. valign="middle" is not working!

<table width="90%" border="0" cellspacing="0" cellpadding="0">
<tr valign="middle">
<td width="20%"><form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-butcc.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHiAY (...) PKCS7-----">
</form></td>
<td>Sample Text</td>
</tr>
</table>


When posting code please use code tags. There are PHP, HTML and CODE tags that can be used while posting code segments.
  • 0

#2 McZika

McZika

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 21 March 2007 - 07:07 AM

The text IS displayed in the center of the field. (try changing the border to 1 and you will see for yourself :))

the problem is with the picture. The pic is displayed in the top left corner of the cell, and because of all the hidden input tags there is some white space below the picture and because of it it seems like the texk is on the bottom of the imege.

So either remove the hidden input tags, or try messing with the styles...
  • 0

#3 John

John

    CC Mentor

  • Moderator
  • 4450 posts
  • Location:New York, NY

Posted 22 March 2007 - 07:04 PM

The text IS displayed in the center of the field. (try changing the border to 1 and you will see for yourself :))

the problem is with the picture. The pic is displayed in the top left corner of the cell, and because of all the hidden input tags there is some white space below the picture and because of it it seems like the texk is on the bottom of the imege.

So either remove the hidden input tags, or try messing with the styles...


Im not sure it has anything to do with the hidden inputs or forms. If you try with just an image, with out any forms, it still behaves the same way.

Just out of curiosity, is there a reason you CANT use a table?
  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download