943,965 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Nov 5th, 2009
0

valign='middle' not working!!

Expand Post »
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?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster
MDanz is offline Offline
146 posts
since Sep 2009
Nov 5th, 2009
0
Re: valign='middle' not working!!
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.
Reputation Points: 120
Solved Threads: 61
Posting Pro
Troy III is online now Online
511 posts
since Jun 2008
Nov 8th, 2009
0
Re: valign='middle' not working!!
all u need to do is center the image inside the div
Reputation Points: 15
Solved Threads: 7
Posting Pro in Training
SKANK!!!!! is offline Offline
428 posts
since Apr 2009
Nov 8th, 2009
0
Re: valign='middle' not working!!
Sorry for asking but
Are you sure you understand his question?
Reputation Points: 120
Solved Threads: 61
Posting Pro
Troy III is online now Online
511 posts
since Jun 2008
Nov 9th, 2009
0
Re: valign='middle' not working!!
yes ansn i also understnad the first answer how it doesnt align the children
Reputation Points: 15
Solved Threads: 7
Posting Pro in Training
SKANK!!!!! is offline Offline
428 posts
since Apr 2009
Nov 9th, 2009
0
Re: valign='middle' not working!!
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.
Reputation Points: 120
Solved Threads: 61
Posting Pro
Troy III is online now Online
511 posts
since Jun 2008
Nov 10th, 2009
0
Re: valign='middle' not working!!
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.
Reputation Points: 15
Solved Threads: 7
Posting Pro in Training
SKANK!!!!! is offline Offline
428 posts
since Apr 2009
Nov 10th, 2009
0
Re: valign='middle' not working!!
Sorry, but css: vertical-align has no effect on divs, -therefore ...
Reputation Points: 120
Solved Threads: 61
Posting Pro
Troy III is online now Online
511 posts
since Jun 2008
Nov 11th, 2009
0
Re: valign='middle' not working!!
im sorry did i forget to mention the div should be the size as the image in height? then its vertically centered hon
Reputation Points: 15
Solved Threads: 7
Posting Pro in Training
SKANK!!!!! is offline Offline
428 posts
since Apr 2009
Nov 11th, 2009
0
Re: valign='middle' not working!!
:') no not even then lady skunk, not even then. :'D
Reputation Points: 120
Solved Threads: 61
Posting Pro
Troy III is online now Online
511 posts
since Jun 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in HTML and CSS Forum Timeline: External CSS problems.
Next Thread in HTML and CSS Forum Timeline: google on firefox address bar





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC