size a DIV as large as needed to fit contents

  • Thread starter Thread starter JezB
  • Start date Start date
J

JezB

I have a DIV whose contents varies in size according to data. How can I size
the DIV precisely to fit it's contents ?
 
what do you mean ?

the only thing you can really do design wize.... is to allow full expansion
to scale with the window.

OR constict the wide and let the length flow
 
Any suggestions are very welcome - thanks.

Eliyahu Goldin said:
Ok, I am taking a risk of getting into your "Block sender" list.

If you use a table, you can put the content you want to be inside the div
into a td. You can format td itself instead of div or you can put a div into
the td with width and height=100%. The td will adjust its size according to
data.

If you don't want table-related suggestions anymore, put a note in your
messages "no tables please".

Eliyahu
 
Ok, I am taking a risk of getting into your "Block sender" list.

If you use a table, you can put the content you want to be inside the div
into a td. You can format td itself instead of div or you can put a div into
the td with width and height=100%. The td will adjust its size according to
data.

If you don't want table-related suggestions anymore, put a note in your
messages "no tables please".

Eliyahu
 
Don't size it at all. Then it will precisely fit its contents.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Good idea! But that only seems to work for height, the width of my DIV seems
to default to the full browser width.
 
It is a block element. It will expand horizontally to fit its container.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
JezB said:
Good idea! But that only seems to work for height, the width of my DIV seems
to default to the full browser width.

Just for fun, try style="width: 0" or style="width: 0%".
 
Put it into a table cell.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Our company standards state that "use of tables is to be discouraged" but
goes on to say "light use of tables to solve specific problems is not
condemned - the developer must simply be aware of and document the
implications of table use" - so perhaps in this special instance I can use
them.

Thanks.
 
You can choose when you have a choice. So far you don't. On this newsgroup
by now you have 2 people with table suggestions and none with css one.

Thank you for the links. Note, that the first one is based on the author's
practical experience, whereas the second one is just an abstract statement.

Anyway, wish you good luck on either way. It would be nice if you could tell
us about the solution.

Eliyahu
 
Patience is a virtue, Eliyahu!

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Back
Top