/    Sign up×
Community /Pin to ProfileBookmark

Hi,

I’ve been using tables for long enough and I found them pretty easy and compatible for every browser. But nowadays using tables is getting more and more frown upon mostly because of it being slower. (For layout)
Anyway, I want to know how do you create such code with div?

[CODE]
<table width=”100%”><tr>
<td width=”50″>content</td>
<td>content</td>
<td width=”50″>content</td>
</tr></table>
[/CODE]

The right and left TD width is 20 and as the table width is 100%, it lets the middle TD to stretch itself and fit the browser width. The important thing for me here is that the 3 TDs will stick together no matter how happens to the user. For example I can use such thing for a box, and put 2 curve images on the left and right.

I’ve tried this: (I added the border to see what exactly I’m getting)

[CODE]
<div>
<div style=”width: 50px; border: 1px solid black; float: left;”>content</div>
<div style=”width: 100%; border: 1px solid black; float: left;”>content</div>
<div style=”width: 50px; border: 1px solid black; float: left;”>content</div>
</div>
[/CODE]

In this case, when I make the browser width smaller, the divs won’t stick together and they fall on a new line.

And I tried again this:

[CODE]
<div style=”display: table;”>
<div style=”width: 50px; border: 1px solid black; display: table-cell;”>content</div>
<div style=”width: 100%; border: 1px solid black; display: table-cell;”>content</div>
<div style=”width: 50px; border: 1px solid black; display: table-cell;”>content</div>
</div>

[/CODE]

Seems to work, but I have no idea if this is the best way to do so and of course it fails in IE6.

How it is done with divs that works in any browser?
Thanks for your time

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@unigogoNov 29.2009 — Here's a tool to have you easily design the 3 column layout - left fixed, middle liquid, right fixed in DIV

http://www.pagecolumn.com/liquidfixed/3_col_fix-liquid-fix.htm
Copy linkTweet thisAlerts:
@opifexNov 29.2009 — I think you want something like this. It's a 3 column fluid layout.

Hope that helps.
×

Success!

Help @asmith20002 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 5.7,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...