valign='middle' not working!!

Reply

Join Date: Sep 2009
Posts: 22
Reputation: MDanz is an unknown quantity at this point 
Solved Threads: 0
MDanz MDanz is offline Offline
Newbie Poster

valign='middle' not working!!

 
0
  #1
Nov 5th, 2009
i have a variable which is an image

HTML and CSS Syntax (Toggle Plain Text)
  1. $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

HTML and CSS Syntax (Toggle Plain Text)
  1. echo "<td valign='middle'><div class='rollover' align='center'>
  2.  
  3. <a href=\"imageview.php?id=$number\" onmouseover=\"ChgText($keyword)\">$image</a>
  4.  
  5. </div>
  6. </td>";

any ideas?
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 348
Reputation: Troy III will become famous soon enough Troy III will become famous soon enough 
Solved Threads: 42
Troy III's Avatar
Troy III Troy III is offline Offline
Posting Whiz
 
0
  #2
Nov 5th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 290
Reputation: SKANK!!!!! is an unknown quantity at this point 
Solved Threads: 2
SKANK!!!!!'s Avatar
SKANK!!!!! SKANK!!!!! is offline Offline
Posting Whiz in Training
 
0
  #3
Nov 8th, 2009
all u need to do is center the image inside the div
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 348
Reputation: Troy III will become famous soon enough Troy III will become famous soon enough 
Solved Threads: 42
Troy III's Avatar
Troy III Troy III is offline Offline
Posting Whiz
 
0
  #4
Nov 8th, 2009
Sorry for asking but
Are you sure you understand his question?
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 290
Reputation: SKANK!!!!! is an unknown quantity at this point 
Solved Threads: 2
SKANK!!!!!'s Avatar
SKANK!!!!! SKANK!!!!! is offline Offline
Posting Whiz in Training
 
0
  #5
Nov 9th, 2009
yes ansn i also understnad the first answer how it doesnt align the children
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 348
Reputation: Troy III will become famous soon enough Troy III will become famous soon enough 
Solved Threads: 42
Troy III's Avatar
Troy III Troy III is offline Offline
Posting Whiz
 
0
  #6
Nov 9th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 290
Reputation: SKANK!!!!! is an unknown quantity at this point 
Solved Threads: 2
SKANK!!!!!'s Avatar
SKANK!!!!! SKANK!!!!! is offline Offline
Posting Whiz in Training
 
0
  #7
Nov 10th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 348
Reputation: Troy III will become famous soon enough Troy III will become famous soon enough 
Solved Threads: 42
Troy III's Avatar
Troy III Troy III is offline Offline
Posting Whiz
 
0
  #8
Nov 10th, 2009
Sorry, but css: vertical-align has no effect on divs, -therefore ...
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 290
Reputation: SKANK!!!!! is an unknown quantity at this point 
Solved Threads: 2
SKANK!!!!!'s Avatar
SKANK!!!!! SKANK!!!!! is offline Offline
Posting Whiz in Training
 
0
  #9
Nov 11th, 2009
im sorry did i forget to mention the div should be the size as the image in height? then its vertically centered hon
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 348
Reputation: Troy III will become famous soon enough Troy III will become famous soon enough 
Solved Threads: 42
Troy III's Avatar
Troy III Troy III is offline Offline
Posting Whiz
 
0
  #10
Nov 11th, 2009
:') no not even then lady skunk, not even then. :'D
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the HTML and CSS Forum


Views: 747 | Replies: 10
Thread Tools Search this Thread



Tag cloud for HTML and CSS
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC