INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Table Body colums do not match fixed header

Table Body colums do not match fixed header

(OP)
Ok I really need this to work, and I've been beating my head against the wall too long already so any help would be GREATLY appreciated. Everything is working great with code show below except, the column widths in the tbody do not match the column widths in the thead which is a fixed row.

CODE

echo '<div class="outer">';
echo '<div class="inner">';

echo '<table>';

echo '<thead><tr><th>' . implode('</th><th>', $rows[0]) . '</th></tr></thead>';

foreach($rows as $key=>$row):
  
		echo '<tbody>';
		echo '<tr class="row">';
		foreach($rows[0] as $field):
			echo '<td scope="row">';
	                echo isset($row[$field]) ? $row[$field] : ' ';
			echo '</td>';
		endforeach;
		echo '</tr>';

endforeach;
echo '</tbody></table></div></div>'; 


CODE

.outer {
position:relative;
overflow:auto;
padding:4em 0 3em 0;
width:100%;
background:#eee;
margin:0 auto 3em auto;
}

.inner {
overflow:auto;
width:105%;
height:9.6em;
background:#eee;
}

.outer thead tr {
position:absolute;
top:1.5em;
height:1.5em;
left:0;
}

.outer th, .outer td {
width:200px; 
text-align:center;
}
.outer th {
background:#724a10; 
color:#fff;
}

.outer .row {
width:200px; 
background:#fff;
} 

RE: Table Body colums do not match fixed header

(OP)
Isn't that what is holding my header in place when I scroll through the body?

RE: Table Body colums do not match fixed header

You should use position: fixed for that, and when an element is positioned as absolute or fixed, it is taken out of the document flow and does not affect other elements. So your 'table header' is effectively not part of the table.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close