DIV wider than TD (cell)

G

gorbus

I put DIV into table cell. DIV is POSITION:RELATIVE. TOP and LEFT
properties of DIV works fine but not WIDTH. When DIV is wider than TD,
TD is also wider... WHY ?


Gorb

PLEASE help
 
E

Els

gorbus said:
I put DIV into table cell. DIV is POSITION:RELATIVE. TOP and LEFT
properties of DIV works fine but not WIDTH. When DIV is wider than TD,
TD is also wider... WHY ?

Because that's what TD's do. What would be the result you're after?
 
G

gorbus

In short: I'd like to show div which is bigger than td. I inserted it
into TD, because I want to position DIV relatively to TD. Is it
possible ?
And of course: TD cannot change its size....
 
E

Els

gorbus said:
In short: I'd like to show div which is bigger than td. I inserted it
into TD, because I want to position DIV relatively to TD. Is it
possible ?
And of course: TD cannot change its size....

This makes no sense to me, but maybe what you are looking for, is
position:absolute, not relative. To make it relative to the TD, you
could give that TD position:relative, and the DIV position:absolute.

It does sound like a very ugly hack though, for something that most
likely could be done in a proper way. However, without seeing your
page or understanding your objective, I can't offer a different
method.
 
G

gorbus

I did as u said but it didn't help - TD is still 200px and should be
100px (when rendered of course):

<TD style="WIDTH: 100px; POSITION: relative" vAlign="top" width="100"
height="100">

<DIV style="LEFT: 50px; WIDTH: 200px; POSITION: relative;
BACKGROUND-COLOR: red">sample text</DIV>

</TD>
 
E

Els

gorbus said:
I did as u said but it didn't help - TD is still 200px and should be
100px (when rendered of course):

<TD style="WIDTH: 100px; POSITION: relative" vAlign="top" width="100"
height="100">

<DIV style="LEFT: 50px; WIDTH: 200px; POSITION: relative;
BACKGROUND-COLOR: red">sample text</DIV>

</TD>

If only you would quote the relevant bits of the message you are
replying to, you would notice a very distinct discrepancy between what
I wrote and what you did.

Hint: relative != absolute

;-)
 
A

Animesh Kumar

gorbus said:
I did as u said but it didn't help - TD is still 200px and should be
100px (when rendered of course):

<TD style="WIDTH: 100px; POSITION: relative" vAlign="top" width="100"
height="100">

You may also want to put a semi-colon after "relative" and "color: red"
in the style field. (Just to be safe).
 
N

Noodles Jefferson

In short: I'd like to show div which is bigger than td. I inserted it
into TD, because I want to position DIV relatively to TD. Is it
possible ?
And of course: TD cannot change its size....

Your div's going to be forced to fit the td. Now, you can position the
div within the td through say <div style="vertical-align:top"> or <div
style="padding-left:.3em"> (for example) but it's still not going to be
bigger than your td. Once you use table, the boxes are pretty much
locked down to a set position. Now, you can use the rowspan and colspan
to get a big td instead of say two little td's, just don't forget that
each cell you do like that means less cells in whichever rows apply.

<table border="1">
<tr>
<td colspan="2">This takes up two td's horizontally</td>
<td>This would be the one on the end</td>
</tr>
<td rowspan="2">This one takes up two td's vertically</td>
<td>This one will be in the middle of the second row</td>
<td>This one's on the end of the second tow.</td>
</tr>
<tr>
<td>This one will be in the middle of the third row</td>
<td>This one will be on the end of the third row</td>
</tr>
</table>


--
Noodles Jefferson
mhm31x9 Smeeter#29 WSD#30
sTaRShInE_mOOnBeAm aT HoTmAil dOt CoM

"Our earth is degenerate in these latter days, bribery and corruption
are common, children no longer obey their parents and the end of the
world is evidently approaching."
--Assyrian clay tablet 2800 B.C.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top