/    Sign up×
Community /Pin to ProfileBookmark

Fluid/Fixed table

Hi Guys

I have a table with 3 rows. What I want to do is set row 1 and 3 to a fixed width of say 50px each and set the second row to fluid. So as the window is resized row 1 and 3 remain the same whereas 2 row grows or shrinks. Here is how far I have got:

Table:

[CODE]<table border=”1″>
<tr>
<td class=”tdDraft”>Draft</td>
<td class=”tdDraftContent”>Dear John Smith…</td>
<td class=”tdDraftDate”>23/Jun/08</td>
</tr>
</table>[/CODE]

CSS:

[CODE]
.tdDraft {
width : 50px;
}
.tdDraftContent {
width : 100%;
}
.tdDraftDate {
width : 50px;
}[/CODE]

This works, but the only problem is that row 2 takes all the space and therefore leaves the other 2 rows squashed.

to post a comment
HTML

2 Comments(s)

Copy linkTweet thisAlerts:
@datapunk79Jul 26.2008 — Your coding is right. The only reason that the two side tables look "squashed" is that they don't have enough content to fill them up. Once you start adding content to them you'll see they'll expand and stop at 50px.
Copy linkTweet thisAlerts:
@ray326Jul 26.2008 — I have a table with 3 rows.[/QUOTE]No, you have a table with 3 [B]columns[/B], the content of which doesn't appear to belong in a table.
... row 2 takes all the space and therefore leaves the other 2 rows squashed.[/QUOTE]You have instructed [B]column[/B] 2 to consume 100% of the width of the row so the other [B]columns[/B] have nowhere to go. You can't mix units in this case, you have to do it all in % or all in hard units or leave the width off the center column and let it do what it wants. Better yet, think about marking up your content meaningfully and doing the presentation later.
×

Success!

Help @Shaolin spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...