Jump to content

CSS Tables - Mystery Space


Andrea

Recommended Posts

My first attempt - and an issue I cannot figure out:

 

http://www.aandbwebdesign.com/builder/

 

Why is there this huge space above the content and navigation??? I have my standard * {margin: 0; padding: 0;} in the css, and other than that, have not even really begun to add margins and padding. So what causes this space? (And it's NOT showing in IE lt 8...

 

And of course ignore the colors and stuff - they are just to show me where what is.

Link to comment
Share on other sites

This worked in Firefox for the left column:-

#navigation { background: green; vertical-align:top;

display: table-cell;

width: 200px;

border: 1px solid red;

}

#navigation ul { background: olive; }

 

I added background colors and you can see that the #navigation does extend the full height but the ul tag inside was centering to the middle vertically.

 

I can't get the layout to work at all in IE7, even after deleting the conditional comment. (Note: the comment should be

Edited by Wickham
Link to comment
Share on other sites

Thanks - IE7 (and 6) would not work WITHOUT the conditional comments, they don't recognize the display table. The conditional css just floats the divisions for everything less than IE 8 instead of displaying them as table cells (since they can't).

 

Didn't realize about the vertical align - back to the book.

Link to comment
Share on other sites

I recently read "Everything you know about CSS is wrong!" which is all about divs DISPLAYING as table cells, so I thought I'd use this project (finally have one after many many months (ok - more like 3 years or so..)) to try it out. It does require a conditional stylesheet for IE7 and older, but I think I can live with that.

Link to comment
Share on other sites

lm - I'll look into grids next time. This time, I want to play around with this.

 

P.S. Maybe I need another lifetime...?
It'll have to be in a future one for sure - none of the past ones included any computer usage.....
Link to comment
Share on other sites

Okay, I just played with it a little and was able to remove the space.

 

#row {

display:table-row;

}

 

#navigation {

display: table-cell;

vertical-align:top;

width: 200px;

border: 1px solid red;

}

 

#content {

display: table-cell;

vertical-align:top;

width: 570px;

background: #639d3b;

padding: 0 25px;

border: 1px solid yellow;

}

 

And then I added a new containing div called #row inside the #main div. It works for me in Firefox 3.5.4.

 

I got the idea from here:

 

http://www.sitepoint.com/blogs/2008/02/28/table-based-layout-is-the-next-big-thing/

 

A longstanding bug in Firefox makes it necessary to add a second containing
inside the "body"
and set it to display: table-row. Otherwise, the layout will often break when it initially loads.
Link to comment
Share on other sites

It is by Rachel Andrew and Kevin Yanks - but it's the book.

 

And according to it, if no table-row display is used, it's assumed, so not needed. It probably does just need the vertical-align top, as Wickham pointed out. Just haven't had time to re-read that chapter in its entirety.

Link to comment
Share on other sites

No, I hadn't sen your second post - thanks. I'll try that when I get home.

 

It was fun exploring at first, but the way this is going, it's taking too much extra to make something work that's supposed to be simpler - not to mention the conditional stylesheet I'll have to build for IE <8. I might just go back to the old way and float something.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...