473,405 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Using <DIV> to mimic a bare <TABLE>

Hi,

I'm wondering how can I use <DIV> to mimic a <TABLE>.

In a bare <TABLE> without a width attribute, the width of the table get
dynamically expanded according to the content. However, <DIV> doesn't have
the same behavior.

In the CSS of the DIV tag, I have: background: #FF0000; to see the area
covered by <DIV>. It appears that <DIV> covers the entire row even if width
is set to "auto" in CSS (auto = 100%?).

I can put a "float: left;" with "width:auto;" and the width of DIV does
become dynamically expanded. However, the content below the DIV tag will now
attach to the right side of the DIV. How do I put a row break there?

Thanks in advance,
--
He Shiming
Jul 24 '05 #1
4 10320
Els
He Shiming wrote:
I can put a "float: left;" with "width:auto;" and the width of DIV does
become dynamically expanded. However, the content below the DIV tag will now
attach to the right side of the DIV. How do I put a row break there?


"clear:left;" on the following element.

--
Els http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Now playing: Sade - Your Love Is King
Jul 24 '05 #2
Thanks it works.

--
He Shiming

"Els" <el*********@tiscali.nl> wrote in message
news:5q****************************@40tude.net...
He Shiming wrote:
I can put a "float: left;" with "width:auto;" and the width of DIV does
become dynamically expanded. However, the content below the DIV tag will
now
attach to the right side of the DIV. How do I put a row break there?


"clear:left;" on the following element.

--
Els http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Now playing: Sade - Your Love Is King

Jul 24 '05 #3
Well, I've got more problems here.

With clear:left, <DIV> still doesn't behave like <TABLE>. I have the
following DIV structure in the page:

<DIV id="outer">
<DIV id="inner">content</DIV>
<DIV id="inner">content</DIV>
</DIV>

As you recommended, I used the following CSS definition for "inner":

width: auto;
float: left;
clear: left;

The "outer" DIV has a colored border, without "clear:left", the border will
surround the "inner" DIVs. But with "clear:left", the "inner" DIVs went out
of the border and the border became a single line. Any ideas?

--
He Shiming

"Els" <el*********@tiscali.nl> wrote in message
news:5q****************************@40tude.net...
He Shiming wrote:
I can put a "float: left;" with "width:auto;" and the width of DIV does
become dynamically expanded. However, the content below the DIV tag will
now
attach to the right side of the DIV. How do I put a row break there?


"clear:left;" on the following element.

--
Els http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Now playing: Sade - Your Love Is King

Jul 24 '05 #4
Els
He Shiming wrote:
Well, I've got more problems here.

With clear:left, <DIV> still doesn't behave like <TABLE>. I have the
following DIV structure in the page:

<DIV id="outer">
<DIV id="inner">content</DIV>
<DIV id="inner">content</DIV>
</DIV>

As you recommended, I used the following CSS definition for "inner":

width: auto;
width:auto; is superfluous for divs, unless you had previously set a
width for divs and you need to 'undo' it for this div.
float: left;
clear: left;

The "outer" DIV has a colored border, without "clear:left", the border will
surround the "inner" DIVs. But with "clear:left", the "inner" DIVs went out
of the border and the border became a single line. Any ideas?


It's not the clear:left that makes the border not stretch, but the
float:left.
To stretch the border around floats, you'll need to put another
element after the floats, but inside he outer div, with clear:both.
This is only needed for non-IE btw, IE does stretch automatically as
long as you set any height or width to outer.

--
Els http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Jul 24 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Philo | last post by:
How do I select all <div> tags except those which contain a <table> tag somewhere within them? Example XML: <********************** sample input ***********************> <txtSectionBody>...
3
by: Paul Thompson | last post by:
When I put a <div ...> inside a <table> specification, functionality is not there. When I put the <table> inside the <div> everything works. Why is that?
1
by: Terry | last post by:
hi guys, could anyone help me with this? I tried to put a <div> in a <td>, and a <table> in that <div>. It looks fine, but my div can't fit in my <td>, there's always a space between the bottom of...
7
by: Herbman | last post by:
Hi, I'm trying to position a <tr> ("row") element with CSS. The table itself is positioned with <div> tags. The problem is when I use <div> tags to position the rows within the table nothing...
19
by: CMAR | last post by:
I have the following markup. The problem is that the browser, e.g., IE6, inserts several lines of blank space between the <div> and the following table. Is there a way to minimize that vertical...
44
by: Jim M | last post by:
I have had great success with using <iframe> with overflow-y set to auto. I can get a similar look with the <iframe> tag. BUT... In all cases I need to have fixed heights. Is there a way to...
1
by: Sean | last post by:
I have a table (with tabular data) that I want to display on a webpage. Initially the talbe is empty. When a user clicks on a button, a child window opens up with a form and some text fields. ...
2
by: billflu | last post by:
I have a two column table. That looks like this. ____________________ | | | |-----| | | | | | | | | | | |____...
10
by: neverquit | last post by:
hi , Iam Nagesh,Begineer in using Ajax,well i have been using ajax in application, i have faced a problem while placing the responseTEXT into the <div> tag positioned inside the <form> tag iam...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.