Forum Moderators: open

Message Too Old, No Replies

Different cellspacing widths

         

RaefWolfe

2:43 am on Jan 22, 2006 (gmt 0)

10+ Year Member



Is there a way to have spacing on one side of a cell, but not the others? I looked all over, but non worked with my code. I have 4 cells but I want it to look like 2 collumns and not four separate cells, so I'd like cellspacing on the sides but not top and bottom.

inveni0

4:54 am on Jan 22, 2006 (gmt 0)

10+ Year Member



Are you talking about the colspan attribute?

RaefWolfe

2:29 pm on Jan 22, 2006 (gmt 0)

10+ Year Member



No.

I have 4 table cells. 3 of them have content. I can use colspan on the lefthand collumn, but not on the right, because both on the right have content.

And I can't move the content to one table cell because then I'm back to my problem of centered something at the bottom of a SSI.

Here's my bare-bones relevant code:

<table width="100%" height="100%" cellpadding="5px">
<tr>
<td>
Cell one has a navbar
</td>
Cell 2 has the main content
</td>
</tr>
<tr>
<td id="navbar">
Cell three (blank)
</td>
<td id="mainstuff">
<img src="my image"> (Cell four)
</td>
</tr>
</table>

inveni0

2:56 pm on Jan 22, 2006 (gmt 0)

10+ Year Member



Is cell three blank, or does it have a nav bar?

rocknbil

8:05 pm on Jan 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If I get you right - completely blank cells act differently in different browsers. Change this

{Cell three (blank)}
<td id="navbar">
</td>

to this
<td id="navbar">&nbsp;</td>

I'm a bit confused as to why cell one actually has the navbar and cell 3 is id'ed as navbar but I'll let you figure that one out. :-)

The above solution may STILL act differently in different browsers and not space the way you'd like, even if you apply CSS rules to explicitly assign it a width. If all else fails, you may have to create a 1x1 pixel transparent image and assign it to that blank space. You can give it any size, the 1x1 pixel image will speed downloading. This is a HACK that is as depricated as using tables for layout but it still works.

<td id="navbar"><img src="spacer.gif" width="24" height="1" border="0" alt=""></td>

RaefWolfe

8:21 pm on Jan 22, 2006 (gmt 0)

10+ Year Member



It is IDed as Navbar because of the CSS that I have applied to it. But it is blank, as I said.

None of this fixes the question that I asked in the first place. I don't care at all about the other cells, because I know the solution for my empty cell.

I want to remove the border between Cell 2 and Cell 4. Is there a way I can make what I want more clear?

jessejump

9:19 pm on Jan 22, 2006 (gmt 0)

10+ Year Member



>>>>>> </td>
Cell 2 has the main content
</td>

This ain't right.

RaefWolfe

11:03 pm on Jan 22, 2006 (gmt 0)

10+ Year Member



And, pray tell, why not?

Cell 1 has a nav bar

Cell 2 has main content, a SSI.

Cell 3 is blank.

Cell 4 has an image.

edit: terrible typo. Never post after naptime :P

jessejump

11:44 pm on Jan 22, 2006 (gmt 0)

10+ Year Member



The content is not in a cell <td>Content</td>

RaefWolfe

12:27 am on Jan 23, 2006 (gmt 0)

10+ Year Member



Well, in my code it's right. When I deleted the worthlessness I must have deleted that too.

jessejump

1:45 am on Jan 23, 2006 (gmt 0)

10+ Year Member



***** I'd like cellspacing on the sides but not top and bottom.

<td><div style="margin: 0 10px">Qwerty</div></td>

RaefWolfe

8:58 pm on Jan 23, 2006 (gmt 0)

10+ Year Member



Didn't work.

jessejump

10:51 pm on Jan 23, 2006 (gmt 0)

10+ Year Member



Oh.

RaefWolfe

1:29 pm on Jan 24, 2006 (gmt 0)

10+ Year Member



Sorry.

Is there anyone else who'd like to give it a shot?

Span

2:38 pm on Jan 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What you need is border-spacing [meyerweb.com] but that doesn't do anything in IE.

jessejump's method should work in a table with cellpadding and cellspacing set to 0.

Or maybe another way is to use transparent left and/or right borders on the <td>s to imitate cellspacing.


table td {
padding:5px;
border-right:10px solid transparent;
}


<table cellspacing="0" cellpadding="0">

RaefWolfe

4:18 pm on Jan 24, 2006 (gmt 0)

10+ Year Member



Neither worked.

Span

7:46 pm on Jan 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok. Well then, another idea, have to waste some bandwidth here, but try copying, pasting and previewing this example:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title>Untitled</title>
<style type="text/css" media="all">
body {
background:orange;
}
table {
background:yellow;
}
table td {
padding:10px;
border-left:20px solid orange;
}
</style>
</head>
<body>
<table cellspacing="0" cellpadding="0">
<tr valign="top">
<td><h3>Navigation cell 1</h3>
<ul>
<li>link</li>
<li>link</li>
<li>link</li></ul></td>
<td><h1>Content - cell 2</h1>
<p>Praesent scelerisque dictum leo. Vestibulum lobortis sapien et felis. In hac habitasse platea dictumst. Aenean eget pede. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean porta pharetra diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vivamus quis elit non est commodo luctus. Sed turpis massa, fringilla ut, vulputate aliquam, sagittis sed, urna. Nulla suscipit mauris eget eros. Phasellus dolor. Aenean laoreet tellus quis diam. Suspendisse est. Donec vitae mauris. Morbi rutrum. Proin luctus commodo nibh.</p>
<h2>More content</h2>
<p>Praesent scelerisque dictum leo. Vestibulum lobortis sapien et felis. In hac habitasse platea dictumst. Aenean eget pede. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean porta pharetra diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vivamus quis elit non est commodo luctus. Sed turpis massa, fringilla ut, vulputate aliquam, sagittis sed, urna. Nulla suscipit mauris eget eros. Phasellus dolor. Aenean laoreet tellus quis diam. Suspendisse est. Donec vitae mauris. Morbi rutrum. Proin luctus commodo nibh.</p>
<h2>More content</h2>
<p>Praesent scelerisque dictum leo. Vestibulum lobortis sapien et felis. In hac habitasse platea dictumst. Aenean eget pede. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean porta pharetra diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vivamus quis elit non est commodo luctus. Sed turpis massa, fringilla ut, vulputate aliquam, sagittis sed, urna. Nulla suscipit mauris eget eros. Phasellus dolor. Aenean laoreet tellus quis diam. Suspendisse est. Donec vitae mauris. Morbi rutrum. Proin luctus commodo nibh.</p></td></tr>
<tr valign="top">
<td>Cell 3</td>
<td><h3>More content in cell 4</h3>
<p>Praesent scelerisque dictum leo. Vestibulum lobortis sapien et felis. In hac habitasse platea dictumst. Aenean eget pede. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean porta pharetra diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vivamus quis elit non est commodo luctus. Sed turpis massa, fringilla ut, vulputate aliquam, sagittis sed, urna. Nulla suscipit mauris eget eros. Phasellus dolor. Aenean laoreet tellus quis diam. Suspendisse est. Donec vitae mauris. Morbi rutrum. Proin luctus commodo nibh.</p></td></tr></table>
</body>
</html>

jessejump

7:51 pm on Jan 24, 2006 (gmt 0)

10+ Year Member



<td><div style="margin: 0 10px">Qwerty</div></td>

This works.
Text is moved 10 px away from td sides.

RaefWolfe

7:53 pm on Jan 24, 2006 (gmt 0)

10+ Year Member



I'll have to try that.

No, jesse. I wish I could show you my page to show what is going on, but short of copying and pasting my entire code here, I can't. I didn't want the text moved away from the sides. I wanted two cell borders gone.

RaefWolfe

7:59 pm on Jan 24, 2006 (gmt 0)

10+ Year Member



Okay, I have borders (thanks to the long code above, I understand it), but the problem is that I want the borders invisible...I mean, I want there to be a space, but not a colored border. But when I make them invisible, well, then it looks like I don't even have a border, which rather defeats the purpose.

Span

8:04 pm on Jan 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you're not using background images on the page body, you could give the table borders the same color as the page background?

RaefWolfe

12:00 am on Jan 25, 2006 (gmt 0)

10+ Year Member



I am useing a background image. It's a varying color one, too, so I can't try and go for the 'average shade' of a color.