Jump to content

table trouble


Guest edwinsweep

Recommended Posts

Guest edwinsweep
hi everybody, i just created a new page with a table layout.
it has 2 rows.
1 at top with width of 100%, this is the header!
and another row under that. containing 2 table cells.
1 for the menu and 1 for the content.
but when the content cell becomes longer than the page can handle, you get a scrollbar!
this is normal, but when this scrollbar comes, the top table row changes size.
its only 1 or 2 pixels, but very anoying when it has to fit a picture!
here is the code
[CODE]
<style type="text/css">
body {
background: white;
margin:0px;
right:0px;
}
</style>
<php
include ('dbcon.inc.php');
$mainpage = 'forum/index.php';
//$mainpage = "testpg.php";
echo '<table border=1 width=100% height=100% cellspacing=0 cellpadding=0><tr height=100><td colspan=3>top</td></tr>';
echo '<tr height=85%><td width=12% rowspan=10>1</td><td width=76%>'; include($mainpage); echo'</td><td width=12%>3</td></tr>';
//echo '<tr><td colspan=2>hoi</td></tr>';
echo '</table>';
?>
[/CODE]
does anybody know why this is happening?
i tryed to change it with css, so that the scrollbar will always be visible.
but even then it changes the size of the top row!
thanks in advance!
Link to comment
Share on other sites

Its a bit hard to post a reply to this sort of question when there is more info needed.
What resolution are you planning on running this layout on ?
Does the background of the header have a constant color to match the image you are placing there ?

Percentages as widths will always change the size of the header across different resolutions. There two options you have, either you can choose a fixed width of lets say 775px catering for  the smallest resolution of 800x600 therefor the header will never change size. or you can make the table 90% wide and use a style to align it in the middle in which case the image you place in the header would have to be centered and the backgroung color of the row matching the background color of the image. I presume the second one is what you are insterested in so here is the code i have come up with.

[code]
<html>
<head>
<style type="text/css">
body {
background: white;
margin:0px;
right:0px;
}
</style>
</head>
<body>
<?php
echo "<table border=\"1\" width=\"90%\" height=\"100%\" cellspacing=\"0\" cellpadding=\"0\" style=\"margin:0 auto 0 auto\">\n";
echo "<tr height=\"100\">\n";
echo "<td colspan=\"3\">top</td>\n";
echo "</tr>\n";
echo "<tr height=\"85%\">\n";
echo "<td width=\"12%\" rowspan=\"10\">
<br />
<br />
<br />
<br />
</td>\n";
echo "<td width=\"76%\">middle</td>\n";
echo "<td width=\"12%\">3</td>\n";
echo "</tr>\n";
echo "</table>\n";
?>
</body>
</html>
[/code]

Another option is to have javascript write the page for you given the users resolution and depending on the resolution make use of different size images for the header, that way you would be able to set the size without using percentages preventing the pixel change you dislike

Hope this helps ya
Ciao for now
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.