Help - Search - Members - Calendar
Full Version: <td> widths
HTMLHelp Forums > Web Authoring > Cascading Style Sheets
gigatech
Hi people...

I have been working for too long on this wacko.gif , lets see what you guys and gals can do...

Simple table with long content including spaces

what I want is to NOWRAP (single height cells - NOT the problem) fixed width (20px, 30px... - THE problem)
AND if the overall width of the table is wider than the screen put a scroll bar on it!! - (NOT the problem)

it doesn't work it I set width:20px; in the CSS AND/OR in the <td>, please help...

many Thanks...

// Code ########################
<head>
<style type="text/css">
body {text-align:center;background-color:#242424;border:0px;}
*,p {font-family:Verdana;color:#CCCCCC;font-size:8pt;}
.wrapper {width:100%;overflow:auto;}
table {border:0px;padding:0px;margin:0 auto;border-collapse: collapse;}
tr {border:0px;padding:0px;margin:0 auto;}
td {border:1px gray solid;padding:0px;margin:0 auto;text-align:left;white-space:nowrap;}
</style>
</head>
<body>
<div class="wrapper">
<table>
<tr>
<td width="20px">1111 1111 11111 11111 1111111 111111 1111 11111 111</td>
<td width="30px">>222 2222222 2222222 2222222222 2222222 2222222 2222</td>
<td width="40px">>333 33333 333333 333333333 333333 3333333 33333333</td>
<td width="50px">>4444444444444444 4444444444444444 4444444444444 444</td>
<td width="60px">>5555555555555 55555555555 5555555555 555555555 5555</td>
<td width="70px">>66666 66 666666 6666666 66666 66666666 6666666 6666</td>
</tr>
<tr>
<td>.</td>
<td>.</td>
<td>.</td>
<td>.</td>
<td>.</td>
<td>.</td>
</tr>
</table>
</div>
</body>
</html>
// Code End ########################
pandy
What do you want to happen when the content is wider than the TD?

Maybe 'overflow' is what you are looking for. You'd need to wrap each cell's content in a DIV or something though and use overflow with that.
http://www.w3.org/TR/CSS2/visufx.html#propdef-overflow
gigatech
the content that is longer than the cell should not be shown

so if the cell is say 20 and the contents is 60 then 40 not show...

Many thanks for the reply pandy but, I have been playing with overflow, just cant seem to get it to work...
gigatech
Thanks for the pointer...

I put a <div> in each cell, set the width and overflow of the <div> then set the width of the cell....

Thanks again....


// Code #############################
<head>
<style type="text/css">
body {text-align:center;background-color:#242424;border:0px;}
*,p {font-family:Verdana;color:#CCCCCC;font-size:8pt;}
.wrapper {width:100%;overflow:auto;}
table {border:0px;padding:0px;margin:0 auto;border-collapse: collapse;}
tr {border:0px;padding:0px;margin:0 auto;}
td {border:1px gray solid;padding:0px;margin:0 auto;text-align:left;white-space:nowrap;}
.width1 {width:100px;white-space:nowrap;text-align:left;overflow:hidden}
.width2 {width:140px;white-space:nowrap;text-align:left;overflow:hidden}
.width3 {width:180px;white-space:nowrap;text-align:left;overflow:hidden}
.width4 {width:220px;white-space:nowrap;text-align:left;overflow:hidden}
.width5 {width:260px;white-space:nowrap;text-align:left;overflow:hidden}
.width6 {width:280px;white-space:nowrap;text-align:left;overflow:hidden}
</style>
</head>
<body>
<div class="wrapper">
<table>
<tr>
<td width="100px"><div class="width1">1111 1111 11111 11111 1111111 111111 1111 11111 111</div></td>
<td width="140px"><div class="width2">222 2222222 2222222 2222222222 2222222 2222222 2222</div></td>
<td width="180px"><div class="width3">333 33333 333333 333333333 333333 3333333 33333333</div></td>
<td width="220px"><div class="width4">4444444444444444 4444444444444444 4444444444444 444</div></td>
<td width="260px"><div class="width5">5555555555555 55555555555 5555555555 555555555 5555</div></td>
<td width="280px"><div class="width6">66666 66 666666 6666666 66666 66666666 6666666 6666</div></td>
</tr>
<tr>
<td>.</td>
<td>.</td>
<td>.</td>
<td>.</td>
<td>.</td>
<td>.</td>
</tr>
</table>
</div>
</body>
</html>
// Code End #############################
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.