zefs zefs - 1 year ago 62
CSS Question

Position fixed <td> makes element move

I have a table that has 3 columns. I use the middle column for the content and the other 2 have an image that act as a border like so:

border --> ||HEADER || <--- border
||NAV ||
|| ||

I have to use position fixed so that the borders do not move when the page scrolls, here is my code:

<td style="background-image:url(images/vertical.jpg); width:10px; height:100%; background-repeat:repeat-y; vertical-align:top; position:fixed;"></td>

The problem is that when using fixed position my border image moves inside the main content which messes my layout. Weird thing is that this only happen for the Left td. My main content has a fixed width of 990px.

Any ideas?

Screenshot displaying the issue:


Answer Source

For design purpose, table have restrictions (this is only my opinion :-) ). if you stick to your code, then you can use this layout.

your image should have a minimum width of 1010px (10px border, 990px content, 10px border)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    min-width: 1010px;
    background:url(images/vertical.jpg) top center repeat-y;
    margin-left: auto;
    margin-right: auto;
    width: 990px;
    width: 990px;
    <div class="wrapper">
    <table class="contenttable">
        <td>content goes here</td>

also you cloud try the custom Grid CSS generator from 960.gs

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download