Hi,
Maybe this is a simple question, but I can't seem to get it to work.
Let's say I have this table:
<table style="width: 300px">
<tr>
<th>Header</th>
<td>1</td>
<td>22</td>
<td>333</td>
</tr>
</table>
How can I use CSS 2 to make the th take minimal width and let the other
columns divide the rest of width equally. Also I do not know how many
data columns I have. 9 6695
Robert <ro****@noreply .x> wrote: Maybe this is a simple question, but I can't seem to get it to work. Let's say I have this table:
<table style="width: 300px"> <tr> <th>Header</th> <td>1</td> <td>22</td> <td>333</td> </tr> </table>
How can I use CSS 2 to make the th take minimal width and let the other columns divide the rest of width equally. Also I do not know how many data columns I have. http://homepage.ntlworld.com/spartanicus/robert.htm
Note that it's hard to imagine a valid reason to fix the width of a
table, especially when using the px unit and when the content contains
text. If the table is used for layout purposes then the correct answer
is stop doing that.
--
Spartanicus
Robert wrote on 26/04/2005 : Hi,
Maybe this is a simple question, but I can't seem to get it to work. Let's say I have this table:
<table style="width: 300px"> <tr> <th>Header</th> <td>1</td> <td>22</td> <td>333</td> </tr> </table>
How can I use CSS 2 to make the th take minimal width and let the other columns divide the rest of width equally. Also I do not know how many data columns I have.
as you dont know the amount of columns you will have, I am guessing
that these are built dynamically. is that correct? if so, then perhaps
you could do a litle run-time width calculations... .
<psuedo_sorta_c ode>
var_width = 100 / (var_column_cou nt + 1) ; // add one for the <th>
write the var_width to the width placeholder in the HTML template.
(perhaps search_replace the var_width placeholder.
</psuedo_sorta_co de>
your HTML template may look like this.
<table style="width: 300px">
<tr>
<th style="width:{v ar_width}%;">He ader</th>
<td style="width:{v ar_width}%;">1</td>
<td style="width:{v ar_width}%;">22 </td>
<td style="width:{v ar_width}%;">33 3</td>
</tr>
</table>
--
a beef jerky site http://www.choicebeefjerky.com.au
not a beef jerky site http://mycoolwheels.com/vote.cmks
nobody ever dreams of working for the man
Spartanicus wrote: Robert <ro****@noreply .x> wrote:
Maybe this is a simple question, but I can't seem to get it to work. Let's say I have this table:
<table style="width: 300px"> <tr> <th>Header</th> <td>1</td> <td>22</td> <td>333</td> </tr> </table>
How can I use CSS 2 to make the th take minimal width and let the other columns divide the rest of width equally. Also I do not know how many data columns I have.
http://homepage.ntlworld.com/spartanicus/robert.htm
This only works if the number of TD columns are exactly 3.
Note that it's hard to imagine a valid reason to fix the width of a table, especially when using the px unit and when the content contains text.
Because I like the other tables I generate to be of equal size.
If the table is used for layout purposes then the correct answer is stop doing that.
No, it's not for the layout of images or something like that.
Disco Octopus wrote: as you dont know the amount of columns you will have, I am guessing that these are built dynamically. is that correct? if so, then perhaps you could do a litle run-time width calculations... .
Yes I thought about this too. Just was hoping to let CSS work this out
automatically. I guess my expectations for CSS were too high :)
Robert wrote: Disco Octopus wrote:
as you dont know the amount of columns you will have, I am guessing that these are built dynamically. is that correct? if so, then perhaps you could do a litle run-time width calculations... .
Yes I thought about this too. Just was hoping to let CSS work this out automatically. I guess my expectations for CSS were too high :)
Your expectations weren't too high, they were wrong.
CSS is about style not about calculating.
RW
Rob_W wrote: Robert wrote:
Disco Octopus wrote:
as you dont know the amount of columns you will have, I am guessing that these are built dynamically. is that correct? if so, then perhaps you could do a litle run-time width calculations... . Yes I thought about this too. Just was hoping to let CSS work this out automatically. I guess my expectations for CSS were too high :)
Your expectations weren't too high, they were wrong. CSS is about style not about calculating.
Having to divide the width between columns is style.
Robert wrote: How can I use CSS 2 to make the th take minimal width [...]
th {width: 0%;}
--
jmm dash list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Robert wrote : Rob_W wrote: Robert wrote:
Disco Octopus wrote:
as you dont know the amount of columns you will have, I am guessing that these are built dynamically. is that correct? if so, then perhaps you could do a litle run-time width calculations... . Yes I thought about this too. Just was hoping to let CSS work this out automatically. I guess my expectations for CSS were too high :)
Your expectations weren't too high, they were wrong. CSS is about style not about calculating.
Having to divide the width between columns is style.
Indeed, but doing the actual dividing to work out what the width should
be, is not style.
--
a beef jerky web site : http://www.choicebeefjerky.com.au
not a beef jerky web site : http://mycoolfish.com/vote.cmks
dont pick your nose if it is sore
Disco Octopus wrote: Having to divide the width between columns is style.
Indeed, but doing the actual dividing to work out what the width should be, is not style.
If I set the width to a certain percentage there needs to be some
dividing too. To have the ability to set a relative 'weight' does not
make those calculations much harder. Well... it sure would be very
useful I think. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Graham J |
last post by:
Apologies for the partial post that mysteriously escaped as I was composing.
I shall try again.
For many years I have been happily and successfully coding tables such that
the WIDTH
specified in a TD is the complete column width including any CELLPADDING.
For example for a 400 pixel wide table with four 100 pixel wide columns and
10 pixel...
|
by: N. Demos |
last post by:
The following code renders as intended in IE (A TABLE, with cells of
fixed width and height, inside of a DIV with fixed width and height and
overflow set to hidden.) In Firefox, the table cells assume a narrower
with than specified. If I comment out the width for the DIV, then the
cells render with the correct width and height. Why is this...
|
by: javaguy |
last post by:
I have a table I hide show/hide through a pair of divs. The show/hide
part works fine in both Mozilla and MSIE. When switching between the
hide and show versions the Mozilla browser keeps them in small width,
about 740 pixels.
When switching between show/hide with MSIE the "show" table wants to
display about 960 pixels. If I set the...
|
by: Alex Meier |
last post by:
I have the following problem:
I need a simple, tabular layout in a webshop.
- left column: navigation column with approx. 170px width
- right column: content area
the goal: the left column should contain a few "boxes" (these are HTML-
tables) which should be all of the same width.
So, I attributed the left column with 'width="170"' and...
|
by: Jean Pion |
last post by:
Dear readers,
Can anyone explain how to set column width of a table in ccs.
I use the following style in an external stylesheet:
table.tbl { table-layout:fixed; border-top: 5px solid #333; border-collapse:
collapse; background: #fff; width: 95%}
table.tbl td { border-bottom: 1px dashed #33ccff; padding: 2px 5px;
text-overflow:ellipsis;...
| |
by: Stewart |
last post by:
Originally posted in comp.lang.javascript:
Newsgroups: comp.lang.javascript
From: "Stewart"
Date: 23 Aug 2005 02:50:04 -0700
Local: Tues, Aug 23 2005 10:50 am
Subject: FireFox, RemoveChild, AppendChild, making width grow?
Hi,
|
by: Norman L. DeForest |
last post by:
Am I misunderstanding the CSS specifications or is Firefox (version 1.0.6)
(and Opera) doing the wrong thing?
It appears that Firefox 1.0.6 includes the border in width calculations
for tables but not in height calculations.
Oh, and Opera version 8.02 does the same thing.
|<-->| |<-->| <------ border
|<------------>| ...
|
by: Charleees |
last post by:
Hi all,
I have a DataGrid with Template Columns.....
There are LAbels,Linkbuttons in the Single Row..
I have to set the Constant Column width for those Template Columns in
Grid...
Wat actually happens is... when the Text size is too big... the column
|
by: Taras_96 |
last post by:
Hi everyone,
Can anyone tell me why the top paragraph block stretches across the
screen (as you would expect), while the bottom div doesn't stretch
across the entire screen? When I set the width to 100% (which I
interpret as saying 'make this width the same width as the parent
(which is the entire screen)) the div is made just wide enough...
|
by: magnesium |
last post by:
I have this under-construction page, If you try and select the link coming from the bottom with your mouse, you'll notice, that before the actual link is selected, the td background will change. you have to the select the text itself to make the link select. I don't know If I've explained it well... I tried height:100%, and width:100%; in the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |