100% height of a div inside a TD

L

Lamberti Fabrizio

I've got the problem described in the table above.

I've put a div red with some text inside a TD, but its height is less than 100% of TD height as you can see.

I've defined the following styles:

div.test { background-color:red; height:100%; width: 100%; }
table.test { border: 1px solid #CCCCCC; background-color:yellow; }
td.test { border: 1px solid #CCCCCC; }

does anyone know a solution ?

Please help me.

Regards to all

2
2b 1
4 5
7 8
 
M

McKirahan

I've got the problem described in the table above.

I've put a div red with some text inside a TD, but its height is less than 100% of TD height as you can see.

I've defined the following styles:

div.test { background-color:red; height:100%; width: 100%; }
table.test { border: 1px solid #CCCCCC; background-color:yellow; }
td.test { border: 1px solid #CCCCCC; }

does anyone know a solution ?

Please help me.

Regards to all

2
2b 1
4 5
7 8


Change
<TD class=test><DIV class=test>1</DIV></TD>
to
<TD class=test><DIV class=test>1<br>&nbsp;</DIV></TD>
 
L

Lamberti Fabrizio

I can't use your solution, because the table is compiled runtime and so I can't know before the maximum lenght of 1 td for setting the correct width style.

I've got the problem described in the table above.

I've put a div red with some text inside a TD, but its height is less than 100% of TD height as you can see.

I've defined the following styles:

div.test { background-color:red; height:100%; width: 100%; }
table.test { border: 1px solid #CCCCCC; background-color:yellow; }
td.test { border: 1px solid #CCCCCC; }

does anyone know a solution ?

Please help me.

Regards to all

2
2b 1
4 5
7 8


Change
<TD class=test><DIV class=test>1</DIV></TD>
to
<TD class=test><DIV class=test>1<br>&nbsp;</DIV></TD>
 
D

Dave Anderson

Lamberti said:
I've got the problem described in the table above.

I've put a div red with some text inside a TD, but its height is less
than 100% of TD height as you can see.

I've defined the following styles:

div.test { background-color:red; height:100%; width: 100%; }
table.test { border: 1px solid #CCCCCC; background-color:yellow; }
td.test { border: 1px solid #CCCCCC; }

does anyone know a solution ?

I would start by fixing your validation problems, especially the improper
nesting ones:

line 8 column 24 - Warning: missing </font> before <div>
line 8 column 7 - Warning: missing </font> before <div>
line 10 column 1 - Warning: inserting implicit <font>
line 10 column 1 - Warning: inserting implicit <font>
line 10 column 1 - Warning: missing </font> before <style>
line 10 column 1 - Warning: <style> isn't allowed in <font> elements
line 40 column 1 - Warning: <style> isn't allowed in <div> elements
line 40 column 1 - Warning: <style> isn't allowed in <div> elements
line 94 column 53 - Warning: discarding unexpected </font>
line 94 column 60 - Warning: discarding unexpected </font>
line 3 column 7 - Warning: inserting missing 'title' element
line 6 column 1 - Warning: <style> inserting "type" attribute
line 10 column 1 - Warning: <style> inserting "type" attribute
line 41 column 1 - Warning: <style> inserting "type" attribute
line 62 column 1 - Warning: <style> inserting "type" attribute
line 6 column 1 - Warning: trimming empty <style>
line 8 column 24 - Warning: trimming empty <font>
line 8 column 7 - Warning: trimming empty <font>

Then get all of the garbage out. You don't need three instances of the same
style rules. When all is said and done, there is a simple solution. Here is
a complete document that does what you want (and validates):



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Test</title>
<style type="text/css">
table {
width: 300px;
border-collapse: collapse;
border: 1px solid #ccc;
background-color: #ff0;
}
td {
border: 1px solid #ccc;
height: 100%;
}
td div {
background-color: #f00;
height: 100%;
}
</style>
</head>
<body>
<table>
<tr><td>2<br>2b</td>
<td><div>1</div></td></tr>
<tr><td>4</td>
<td>5</td></tr>
<tr><td>7</td>
<td>8</td></tr>
</table>
</body>
</html>



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 

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

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top