Welcome Guest Search | Active Topics | Members | Log In | Register

as small a width as possible

Making a as small a width as possible Options · View
Nathan Sokalski
Posted: Friday, October 05, 2007 4:37:25 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 05/10/2007 16:37:25
Date: Fri, 5 Oct 2007 20:37:25 -0400

I have a <td> that contains several elements, some of which are
left-aligned, right-aligned, or centered. I do not know the widths of these
elements beforehand, so I cannot give my <td> a fixed width. I want the <td>
to have as small a width as possible without causing anything to wrap, but
IE seems to want to make it bigger. Does anybody know of a good way to
prevent a <td> from being stretched to a larger width than necessary?
Thanks.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/


Nathan Sokalski
Posted: Friday, October 05, 2007 6:20:48 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 05/10/2007 18:20:48
Date: Fri, 5 Oct 2007 22:20:48 -0400

Here is an example of a <td> using more space than necessary:

<table>
<tr>
<td>
<span style="float:left;">Float Left</span>
<span style="float:right;">Float Right</span><br/>
<div
style="width:500px;height:500px;background-color:Orange;">&nbsp;</div>
</td>
</tr>
</table>

You will notice that neither the table or td has a set width, but the float
right hangs over the edge of the div. The table could easily be no more than
the width of the div (in this case 500px) and still fit both span tags in.
Do the floats have anything to do with the problem? I use floats because I
want the spans on the left and right of the same line, and in my code the
width of the div is dynamic (my code also involves more cells than this).
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

"Mark Rae [MVP]" <mark@markNOSPAMrae.net> wrote in message
news:u37o8Z7BIHA.4956@TK2MSFTNGP06.phx.gbl...
> "Nathan Sokalski" <njsokalski@hotmail.com> wrote in message
> news:uRgqAE7BIHA.5360@TK2MSFTNGP03.phx.gbl...
>
> [cross-posting removed]
>
>>I have a <td> that contains several elements, some of which are
>>left-aligned, right-aligned, or centered. I do not know the widths of
>>these elements beforehand, so I cannot give my <td> a fixed width. I want
>>the <td> to have as small a width as possible without causing anything to
>>wrap, but IE seems to want to make it bigger. Does anybody know of a good
>>way to prevent a <td> from being stretched to a larger width than
>>necessary?
>
> A <td> will expand to fit its contents. However, if other rows have more
> data in the corresponding cell, then obviously the entire column will
> expand to fit the contents of the largest cell.
>
> Check in View Source for what markup is actually being included in the
> cell in question...
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net


Alexey Smirnov
Posted: Friday, October 05, 2007 10:36:45 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 05/10/2007 22:36:45
Date: Sat, 06 Oct 2007 05:36:45 -0700

On Oct 6, 4:20 am, "Nathan Sokalski" <njsokal...@hotmail.com> wrote:
> Here is an example of a <td> using more space than necessary:
>
> <table>
> <tr>
> <td>
> <span style="float:left;">Float Left</span>
> <span style="float:right;">Float Right</span><br/>
> <div
> style="width:500px;height:500px;background-color:Orange;"> </div>
> </td>
> </tr>
> </table>
>

Hi Nathan

you have to set clear:both to make the div element go below

<div style="CLEAR:BOTH;width:500px;height:500px;background-
color:Orange;">

Hope it helps

Mark Rae [MVP]
Posted: Saturday, October 06, 2007 3:16:14 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 06/10/2007 03:16:14
Date: Sat, 6 Oct 2007 02:16:14 +0100

"Nathan Sokalski" <njsokalski@hotmail.com> wrote in message
news:uRgqAE7BIHA.5360@TK2MSFTNGP03.phx.gbl...

[cross-posting removed]

>I have a <td> that contains several elements, some of which are
>left-aligned, right-aligned, or centered. I do not know the widths of these
>elements beforehand, so I cannot give my <td> a fixed width. I want the
><td> to have as small a width as possible without causing anything to wrap,
>but IE seems to want to make it bigger. Does anybody know of a good way to
>prevent a <td> from being stretched to a larger width than necessary?

A <td> will expand to fit its contents. However, if other rows have more
data in the corresponding cell, then obviously the entire column will expand
to fit the contents of the largest cell.

Check in View Source for what markup is actually being included in the cell
in question...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Singapore Web Design
Posted: Sunday, October 07, 2007 3:04:10 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 07/10/2007 03:04:10
Date: Sat, 6 Oct 2007 19:04:10 +0800

Hello,

If the containing table and td have no width set, the td width will be the
size of the column.

To prevent the wrapping, use the nowrap attribute. See
http://www.htmlcodetutorial.com/tables/_TD_NOWRAP.html

--
Singapore Web Design
http://www.bootstrike.com/Webdesign/
Singapore Web Hosting
http://www.bootstrike.com/WinXP/faq.html
Windows XP FAQ

"Nathan Sokalski" <njsokalski@hotmail.com> wrote in message
news:uRgqAE7BIHA.5360@TK2MSFTNGP03.phx.gbl...
>I have a <td> that contains several elements, some of which are
>left-aligned, right-aligned, or centered. I do not know the widths of these
>elements beforehand, so I cannot give my <td> a fixed width. I want the
><td> to have as small a width as possible without causing anything to wrap,
>but IE seems to want to make it bigger. Does anybody know of a good way to
>prevent a <td> from being stretched to a larger width than necessary?
>Thanks.
> --
> Nathan Sokalski
> njsokalski@hotmail.com
> http://www.nathansokalski.com/
>


Users browsing this topic
Guest

as small a width as possible


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFPro Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.1 (NET v2.0) - 9/10/2007
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.
This page was generated in 0.083 seconds.