473,729 Members | 2,349 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

distribute columns evenly

I have a table that is a menu containing 10 items horizontally. I want
it to be able to stretch across the screen sizing itself appropriately.
I have each item in a separate table cell and I was hoping I could have
the cells spaced evenly-somehow. I tried adding 10% to the CSS, but it
is still spacing them strangley. The longer words have bigger cells of
empty space and the smaller words have no extra width at all.
I'm working in IE6, but want this to work in netscape too.
Example:
fox elephant dog cat hippopatamous fish

I'm using:
<td><div class="cell"><A class="nav">fox </a></div></td>
<td><div class="cell"><A class="nav">ele phant</a></div></td>
<td><div class="cell"><A class="nav">dog </a></div></td>
<td><div class="cell"><A class="nav">cat </a></div></td>
<td><div class="cell"><A class="nav">hip popatamous</a></div></td>
<td><div class="cell"><A class="nav">fis h</a></div></td>

with CSS:
div.cell {width: 100%; text-align: center;}

did some experimenting with:
td a.nav { width: 100%;text-align: center;}
but the div seemed to space a little better

I put width 100% becasue in looking at the design view in Homesite
(which I use only to figure out stuff like this) the <a> or <div> was
around the word but the cell was much larger. This fixed the problem of
the much bigger cell around the big word.

The larger words are still padded a bit in the cell. I would like to
see that fixed and also a way to put even spacing between each
cell--using a cell with a different style? some kind of dynamic width?
Thanks for your help!
Lisa

Jul 21 '05 #1
2 21821
"webmaker" <li******@yahoo .com> wrote:
I have a table that is a menu containing 10 items horizontally. I want
it to be able to stretch across the screen sizing itself appropriately.
The obvious approach is to set the table width to 100% and the column
widths to 10%. If some cell contains a word that is too long to fit into
that 10%, browsers expand that column and shrink the others, and this is a
fairly hard problem. But is it relevant in your case?

I don't see why you are using extra <div> markup. And setting width: 100%
for a <div> inside a <td> simply tells the <div> to use the full width of
the cell (column).
I'm using:
Please post the URL. As far as I can see, the CSS code in the snippets you
posted does not affect column widths and should be expected to affect them.
td a.nav { width: 100%;text-align: center;}
This makes an <a> element occupy the available width, in this case the
cell's width. This might be nice, but it does not set the cell width.
The larger words are still padded a bit in the cell.


No wonder, since default cellpadding is typically nonzero and you don't
seem to be changing that. On the other hand, padding (at least left and
right padding) tends to be a solution rather than a problem. You might wish
to set in CSS, though, instead of the coarse cellpadding=".. ." in HTML.
(E.g., th, td { padding: 0.1em 0.25em; })

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Jul 21 '05 #2
thanks, Jukka. It was the cell padding. I always change it when
chopping up graphics, but didn't even think about it with text.
Lisa

Jul 21 '05 #3

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

Similar topics

3
3150
by: flamesrock | last post by:
Lets say I have a list containing 12, 13, 23 or however many entries. What I want is the greatest number of lists evenly divisible by a certain number, and for those lists to be assigned to variables. This leads to a few problems.. If I don't know the length of the list beforehand, I can't create the variables and hardcode them. Is it possible in python to generate free variables without stating them explicitly in the code, and if so,...
0
2258
by: Old Wolf | last post by:
I have a site that I laid out with tables, and lots of grotty hacks and lots of markup generated by client-side javascript. I'm in the process of converting it to "nice" CSS code but have got stuck on a couple of issues. My pages are going to be used in a situation with fixed viewport (1024x768) and Mozilla browser -- so there are no resizing / browser issues to worry about. My basic page layout is:
5
13163
by: Mark Cave-Ayland | last post by:
Hi everyone, I'm trying to calculate an output column which is the difference of two other columns in the query output; the first column is an aggregate of items in stock, while the second column is an aggregate of items which have been used. The third column should should be the difference of the two values so I can then output all three columns in a table. Unfortunately I can't get this to work at the moment :(. I've simplified the...
0
1166
by: rubino57 | last post by:
I have spent several hours, but not yet able to figure out how to make the rows fit evenly within the display area *without* scrollbars. A code snippet is as follows: For i As Integer = 0 To 44 Dim colName As String = (DirectCast(ChrW(i + start), Char)).ToString() Dim index As Integer = dgShmoo.Columns.Add(i, String.Empty) dgShmoo.Columns(i).SortMode = DataGridViewColumnSortMode.NotSortable
0
1112
by: PromisedOyster | last post by:
I have an ASP menu (.NET 2.0) that is populated from the sitemap (see below for definition). However, I notice that the elements in the menu are not spaced evenly across. Is there any way to enforce this or is there something wrong with the way I am defining the menu?????? <asp:Menu ID="menu" runat="server" DataSourceID="SiteMapDataSource" Orientation="Horizontal" Width="800px"
5
12434
by: Hopp Family | last post by:
Here's the problem. I want to display a known number of images, evenly spaced out across the width of a div. (The images are not all the same width; the centers should be evenly spaced.) The div changes width with the browser, so the layout needs to be fluid. If the div narrows too much, the images should wrap; in this event, the images on each row should be evenly spaced (the spacing can vary from row to row). I can't figure out how to...
1
2888
by: mcneilkm | last post by:
Hi all, I am a newby to this forum. I am making modifications to an existing database. The structure is basicall one primary record in a main table with many associated records in a second table. The associated records has a field in it called hours and is formated as a number. I need to update this field based on criteria in a text box which is also a number. In all the the idea is to take the text box number which represent cuts to the...
2
1863
by: Terry | last post by:
Hi everyone. I am rather new to the css game and as such would appreciate a little help. I have been given the task to create a page which follows the design shown at the following link: http://www.geocities.com/terrance.murray/Restaurant/restaurantdesign.jpg I was wondering would be the best way to position the three images appearing in the grey area evenly. Off hand I think that I could do
2
1526
by: sms1973 | last post by:
Hello, I have built an application web site using ASP.NET 2003 and MSSQL database server. I now need to distribute the entire application to customers on a CD to run the web application completely from their local personal computers. In other words, they will not need to access the Internet to run the application. I know I can use the redistributable MSSQL EMMSDE for the database part, but my problem is that I want users to run the site...
0
8761
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9426
Oralloy
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9200
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
8148
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
6722
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
6022
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
4525
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
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2163
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.