SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    One table cell is possessed, exorcist needed.

    so, using php i'm dynamically getting image locations from my db. every cell is coming out ok except the first.. this cell is twice as long for no particular reason. i used firebug to take a look at what's causing it and it's the div. but the div has no code except to create a margin. firebug shows a border right on all images so it's not the image. and if i set width="100" forget it, all the cells go crazy... i have no idea why this is happening.. please help me i'm losing my mind

    ok this is my output:
    HTML Code:
    <table border="1"><tr>
    	<td width="100%"><div id="img_box"><img src="http://path/e2ed9de205a5ed42_t.jpg"/></div></td> 
    	<td width="100%"><div id="img_box"><img src="http://path/e370158b22f0b1f7_t.jpg"/></div></td> 
    	<td width="100%"><div id="img_box"><img src="http://path/feba234f314fefd0_t.jpg"/></div></td> 
    	<td width="100%"><div id="img_box"><img src="http://path/16e6073e3d65b0f5_t.jpg"/></div></td> 
    	<td width="100%"><div id="img_box"><img src="http://path/861d8aafbfc4247f_t.JPG"/></div></td> 
    </tr></table>

  2. #2
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,702
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Your first TD has to fill 100&#37;, so it has to fill up 100% of the TABLE's width. The rest of the TDs therefore doesn't have much space left (about 0%), and will only have width if they have contents. Basically, you're trying to make your TABLE five times as wide as your TABLE, which will obviously create some problems.

    Furthermore, you can't have more than one instance of each ID for each table, and you have five. Use a class in stead (or, rather, append the class to the TD - there's no reason to have a DIV inside a TD for the some purpose of applying a class).

    You don't have ALT, HEIGHT and WIDTH attributes for your images either, and you should really move your styling to your style sheet (border and width) (but then again, you most likely shouldn't be using a table for this as all).

    What is the actual problem? You've only defined that something is wrong, so it's rather difficult to give an exact reason.
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i would like to not use a table, but then i would have to deal with floats.. i would like to make it to 30years of age without a heart attack .

    my problem is i just want all the cells to be a certain height and width, but it doesn't want to listen. i put a class in the td tag and all styles work except width. why is this?

  4. #4
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Because table cells are designed to adapt to their content.

    You can try using table-layout:fixed for the TABLE element, but you need to set reasonable widths for your cells. Five cells with a 100&#37; width is not reasonable.
    Birnam wood is come to Dunsinane

  5. #5
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,702
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    You're setting your width to 100&#37; for each TD. This means, that if your TABLE is 500 pixels wide, each TD has to be 500 pixels wide. This is a problem.

    Try setting each TD's width to 20%, if you really want to use a TABLE.
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!

  6. #6
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i got rid of the percentages for hardcoded values. i'm going to add that line you suggested a little later.. thanks for your help C. !


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •