473,804 Members | 2,252 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple variable-width columns in a table

I have a problem that can be simplified to the following: I have a
table with three columns. I need the middle column to be fixed width,
let's say 100px. The other two columns I want to be variable width,
such that one (say the left column) will minimize its width to the
smallest it can be while still fitting a short line of text (no more
than 32 characters) on a single line with no breaks. The right column
I would then want to maximize its width to the remainder of the width
on the screen.

My current solution is as follows:

<table width="100%" border="1" cellpadding="0p x"
cellspacing="0p x"><tbody><tr>< td>
Minimize
</td><td style="width:10 0px; min-width:100px; ">
Fixed
</td><td style="width:10 0%; ">
Maximize
</td></tr></tbody></table>

It works in everything but IE (as usual), which doesn't preserve the
fixed width column. Is there a better solution, and if not, how do I
fix this in IE, aside from the natural inclination to direct all IE
users to a page that says "IE sucks".
Sep 27 '08 #1
2 14737
bgold12 wrote:
I have a problem that can be simplified to the following: I have a
table with three columns. I need the middle column to be fixed width,
let's say 100px. The other two columns I want to be variable width,
such that one (say the left column) will minimize its width to the
smallest it can be while still fitting a short line of text (no more
than 32 characters) on a single line with no breaks. The right column
I would then want to maximize its width to the remainder of the width
on the screen.
Even though the idea is simple, it is challenging, since table layout is so
problematic - with browser differences, oddities, and quirks. Moreover, the
idea is not expressible in HTML at all. As fas as I can see, it is not
expressible even in CSS. You can of course express the idea of fixed width
for a column in a sense, but only in a sense. In HTML, <td width="100">
(which you don't use in your code fragment and which wouldn't help in
practice) specifies a suggested _minimum_ width. In CSS, you can say width:
100px, but as you can see, IE won't always obey it. Part of the reason is
that you are also suggesting 100% width for one cell, so your suggestions do
not constitute a coherent set.
My current solution is as follows:
Even in a simple case, it is best to provide a URL, if only to show a good
example.
<table width="100%" border="1" cellpadding="0p x"
cellspacing="0p x"><tbody><tr>< td>
The markup is incorrect, since HTML attributes must not contain the px unit.
In practice, browsers will ignore it, but it's still incorrect.
Minimize
</td><td style="width:10 0px; min-width:100px; ">
Fixed
</td><td style="width:10 0%; ">
Maximize
</td></tr></tbody></table>
So how do you expect browsers to deal with
100% = something + 100px + 100%
? The surprising thing is that some browsers do what you want.
It works in everything but IE (as usual), which doesn't preserve the
fixed width column. Is there a better solution, and if not, how do I
fix this in IE, aside from the natural inclination to direct all IE
users to a page that says "IE sucks".
Such redirection a very good idea at least from the perspective of your
competitors. :-)

Seriously, using inner markup in the middle-column cell seems to help:

<td><div style="width: 100px">...</div></td>

The point is that this sets a minimum width for the contents of the cell.
This will effectively deal with the allocation of width outside the table
layout algorithm, so that the cell content is comparable to an image or
other fixed-size element.

--
Yucca, http://www.cs.tut.fi/~jkorpela/

Sep 27 '08 #2
On 2008-09-27, bgold12 <bg*****@gmail. comwrote:
I have a problem that can be simplified to the following: I have a
table with three columns. I need the middle column to be fixed width,
let's say 100px. The other two columns I want to be variable width,
such that one (say the left column) will minimize its width to the
smallest it can be while still fitting a short line of text (no more
than 32 characters) on a single line with no breaks. The right column
I would then want to maximize its width to the remainder of the width
on the screen.
This may be your best bet:

table { width: 100%; }
#left { width: 1px; white-space: nowrap }
#middle { width: 100px; }

<table border=1>
<tr>
<td id="left">
Minimize
</td>
<td id="middle">
Fixed
</td>
<td id="right">
Maximize
</td>
</tr>
</table>

I don't have IE to test it in. If white-space doesn't work in IE
consider non-standard-but-who-cares <nobrinside the first td.

1px makes the left column as narrow as possible, which means as wide as
the longest word.

The middle is 100px, and the right should take up the rest because the
whole table is 100% and there's nowhere else for the width to go.

Automatic table formatting is not precisely and accurately specified
anywhere, so keep it simple. Avoid asking for the logically impossible
(one column 100px and another 100% for example) because that just takes
you deeper into the woods-- "ab falso quod libet".
My current solution is as follows:

<table width="100%" border="1" cellpadding="0p x"
cellspacing="0p x"><tbody><tr>< td>
Minimize
</td><td style="width:10 0px; min-width:100px; ">
Fixed
</td><td style="width:10 0%; ">
Maximize
</td></tr></tbody></table>

It works in everything but IE (as usual), which doesn't preserve the
fixed width column. Is there a better solution, and if not, how do I
fix this in IE, aside from the natural inclination to direct all IE
users to a page that says "IE sucks".
It may think you want 100% more than you want 100px. It can't really be
blamed for that since you asked for both.
Sep 27 '08 #3

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

Similar topics

1
2021
by: DrewM | last post by:
I'm still thinking about session variables :-) Does anyone know the detail of how session variables are actually stored? The question I'm trying to answer is: Is it more efficient to store and retrieve multiple short strings : a) in multiple small session variables b) concatenated and stored as one large session variable c) inserted into an array and stored in a session variable
17
43963
by: Roland Hall | last post by:
Is there a way to return multiple values from a function without using an array? Would a dictionary object work better? -- Roland Hall /* This information is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. */ Technet Script Center - http://www.microsoft.com/technet/scriptcenter/ WSH 5.6 Documentation -...
5
2479
by: Charles L | last post by:
Can someone explain to me what the following means? "C permits multiple definitions of a variable in any given namespace, provided the definitions are the same and it generates only a single variable for the multiple definitions. C++, however, does not permit redefinition of a variable or any other entity for a very definite reason that we will discuss later." Chapter 1. C++ Tutorial. Coronado Enterprises Charles L
6
4305
by: Ben Hallert | last post by:
Hi guys, I'm trying to figure out what bone headed mistake I made on something I put together. I've got a form (named 'context') that has a variable number of select-multiple inputs on it. Based on the number of variables passed through a GET string, I want to multiply the total number of selected items for each together to see how many possible combinations the selected items are generating. The following snippet of code...
12
3240
by: (Pete Cresswell) | last post by:
I know I can open many instances of a given form, but I've never done it. Now I'm analyzing an application where that seems like just the ticket: Many investment funds, *lots* of data points for each fund, and a desire by the users to see several funds presented side-by-side. Is opening, say, five instances of the same form real-world-doable? -- PeteCresswell
14
2558
by: Carramba | last post by:
hi! I have program with several funktion witch are in separete files, I have one include file were I have definet some variables and initiated 'const double fVar=0.874532;' this files is includet in all other files containing funktions, when I compile I get this error multiple definition of `fVar' why id that? I have only defined it one in include file? --
9
2795
by: lbj137 | last post by:
I have two files: A.c and B.c. In both files I define a global variable, int xxxx; When I compile with a green hills compiler (and also i think with a GNU compiler) I get no errors or warnings. Only when I initialize xxxx to two different values in A.c and B.c respectively do I get a 'multiple definitions' error. I was under the impression that I would get such an error even without initializing xxxx twice, simply because i am (ostensibly)...
15
6634
by: Iced Crow | last post by:
In C# I know that you can use delegates to assing multiple addresses of sub and functions to a delegate and have it fire multiple procedures... How do I do this in VB? I only know of assigning a single method to a delegate in VB.NET. I want to use it as in C#... to fire multiple events. Thanks in advance!
11
22585
by: lars.uffmann | last post by:
Easily described problem: Using g++ version 3.3.5 under suse 9.3, bla.h: ----------- #ifndef myTEST #define myTEST ZFSInt test; #endif
2
2100
by: Immortal Nephi | last post by:
You may have heard diamond shape. You create one base class. One base class has member functions and member variables. You create two derived classes. All member functions and member variables from one base class are inherited into two derived classes. You want both derived classes to share member variables of the one base class. You can do this way so you don't need keyword -- friend. You can add virtual public One_Base_Class on...
0
10346
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10347
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10090
tracyyun
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9173
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7635
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6863
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5531
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3001
bsmnconsultancy
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.