size a DIV as large as needed to fit contents

Discussion in 'ASP .Net' started by JezB, Jul 6, 2004.

  1. JezB

    JezB Guest

    I have a DIV whose contents varies in size according to data. How can I size
    the DIV precisely to fit it's contents ?
    JezB, Jul 6, 2004
    #1
    1. Advertising

  2. JezB

    Darren Clark Guest

    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


    "JezB" <> wrote in message
    news:...
    > I have a DIV whose contents varies in size according to data. How can I

    size
    > the DIV precisely to fit it's contents ?
    >
    >
    Darren Clark, Jul 6, 2004
    #2
    1. Advertising

  3. JezB

    JezB Guest

    Any suggestions are very welcome - thanks.

    "Eliyahu Goldin" <> wrote in message
    news:%...
    > 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
    >
    > "JezB" <> wrote in message
    > news:...
    > > I have a DIV whose contents varies in size according to data. How can I

    > size
    > > the DIV precisely to fit it's contents ?
    > >
    > >

    >
    >
    JezB, Jul 6, 2004
    #3
  4. 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

    "JezB" <> wrote in message
    news:...
    > I have a DIV whose contents varies in size according to data. How can I

    size
    > the DIV precisely to fit it's contents ?
    >
    >
    Eliyahu Goldin, Jul 6, 2004
    #4
  5. 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.

    "JezB" <> wrote in message
    news:...
    > I have a DIV whose contents varies in size according to data. How can I

    size
    > the DIV precisely to fit it's contents ?
    >
    >
    Kevin Spencer, Jul 6, 2004
    #5
  6. JezB

    JezB Guest

    Good idea! But that only seems to work for height, the width of my DIV seems
    to default to the full browser width.

    "Kevin Spencer" <> wrote in message
    news:...
    > 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.
    >
    > "JezB" <> wrote in message
    > news:...
    > > I have a DIV whose contents varies in size according to data. How can I

    > size
    > > the DIV precisely to fit it's contents ?
    > >
    > >

    >
    >
    JezB, Jul 6, 2004
    #6
  7. 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" <> wrote in message
    news:...
    > Good idea! But that only seems to work for height, the width of my DIV

    seems
    > to default to the full browser width.
    >
    > "Kevin Spencer" <> wrote in message
    > news:...
    > > 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.
    > >
    > > "JezB" <> wrote in message
    > > news:...
    > > > I have a DIV whose contents varies in size according to data. How can

    I
    > > size
    > > > the DIV precisely to fit it's contents ?
    > > >
    > > >

    > >
    > >

    >
    >
    Kevin Spencer, Jul 6, 2004
    #7
  8. "JezB" <> wrote in message
    news:...
    > 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%".
    --
    John Saunders
    johnwsaundersiii at hotmail
    John Saunders, Jul 6, 2004
    #8
  9. JezB

    JezB Guest

    But that's exactly what I dont want - I want it only wide enough to fit its
    contents.

    "Kevin Spencer" <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:...
    > > Good idea! But that only seems to work for height, the width of my DIV

    > seems
    > > to default to the full browser width.
    > >
    > > "Kevin Spencer" <> wrote in message
    > > news:...
    > > > 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.
    > > >
    > > > "JezB" <> wrote in message
    > > > news:...
    > > > > I have a DIV whose contents varies in size according to data. How

    can
    > I
    > > > size
    > > > > the DIV precisely to fit it's contents ?
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
    JezB, Jul 6, 2004
    #9
  10. Put it into a table cell.

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

    "JezB" <> wrote in message
    news:#...
    > But that's exactly what I dont want - I want it only wide enough to fit

    its
    > contents.
    >
    > "Kevin Spencer" <> wrote in message
    > news:...
    > > 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" <> wrote in message
    > > news:...
    > > > Good idea! But that only seems to work for height, the width of my DIV

    > > seems
    > > > to default to the full browser width.
    > > >
    > > > "Kevin Spencer" <> wrote in message
    > > > news:...
    > > > > 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.
    > > > >
    > > > > "JezB" <> wrote in message
    > > > > news:...
    > > > > > I have a DIV whose contents varies in size according to data. How

    > can
    > > I
    > > > > size
    > > > > > the DIV precisely to fit it's contents ?
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
    Kevin Spencer, Jul 6, 2004
    #10
  11. JezB

    JezB Guest

    Ha ha - here we go again.

    There is some debate going on about tables vs css for handling page layouts.
    For example :

    http://www.barry.pearson.name/articles/layout_tables/css_positioning.htm
    vs
    http://www.nypl.org/styleguide/css/guidelines.html

    I dont really have enough detailed knowledge to know what is the best way.
    But being new to the arena I have to follow the W3Cs current "best-practice"
    recommendations and go for stylesheets. Well, company guidelines dictate
    that I have to anyway !

    "Eliyahu Goldin" <> wrote in message
    news:eCe48Y$...
    > Thank you Kevin,
    >
    > I was patiently waiting for this.
    >
    > Eliyahu
    >
    > "Kevin Spencer" <> wrote in message
    > news:%...
    > > Put it into a table cell.
    > >
    > > --
    > > HTH,
    > > Kevin Spencer
    > > .Net Developer
    > > Microsoft MVP
    > > Big things are made up
    > > of lots of little things.
    > >
    > > "JezB" <> wrote in message
    > > news:#...
    > > > But that's exactly what I dont want - I want it only wide enough to

    fit
    > > its
    > > > contents.
    > > >
    > > > "Kevin Spencer" <> wrote in message
    > > > news:...
    > > > > 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" <> wrote in message
    > > > > news:...
    > > > > > Good idea! But that only seems to work for height, the width of my

    > DIV
    > > > > seems
    > > > > > to default to the full browser width.
    > > > > >
    > > > > > "Kevin Spencer" <> wrote in message
    > > > > > news:...
    > > > > > > 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.
    > > > > > >
    > > > > > > "JezB" <> wrote in message
    > > > > > > news:...
    > > > > > > > I have a DIV whose contents varies in size according to data.

    > How
    > > > can
    > > > > I
    > > > > > > size
    > > > > > > > the DIV precisely to fit it's contents ?
    > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
    JezB, Jul 7, 2004
    #11
  12. Thank you Kevin,

    I was patiently waiting for this.

    Eliyahu

    "Kevin Spencer" <> wrote in message
    news:%...
    > Put it into a table cell.
    >
    > --
    > HTH,
    > Kevin Spencer
    > .Net Developer
    > Microsoft MVP
    > Big things are made up
    > of lots of little things.
    >
    > "JezB" <> wrote in message
    > news:#...
    > > But that's exactly what I dont want - I want it only wide enough to fit

    > its
    > > contents.
    > >
    > > "Kevin Spencer" <> wrote in message
    > > news:...
    > > > 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" <> wrote in message
    > > > news:...
    > > > > Good idea! But that only seems to work for height, the width of my

    DIV
    > > > seems
    > > > > to default to the full browser width.
    > > > >
    > > > > "Kevin Spencer" <> wrote in message
    > > > > news:...
    > > > > > 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.
    > > > > >
    > > > > > "JezB" <> wrote in message
    > > > > > news:...
    > > > > > > I have a DIV whose contents varies in size according to data.

    How
    > > can
    > > > I
    > > > > > size
    > > > > > > the DIV precisely to fit it's contents ?
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
    Eliyahu Goldin, Jul 7, 2004
    #12
  13. JezB

    JezB Guest

    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.

    "Eliyahu Goldin" <> wrote in message
    news:%...
    > 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
    >
    > "JezB" <> wrote in message
    > news:e03%23k2$...
    > > Ha ha - here we go again.
    > >
    > > There is some debate going on about tables vs css for handling page

    > layouts.
    > > For example :
    > >
    > > http://www.barry.pearson.name/articles/layout_tables/css_positioning.htm
    > > vs
    > > http://www.nypl.org/styleguide/css/guidelines.html
    > >
    > > I dont really have enough detailed knowledge to know what is the best

    way.
    > > But being new to the arena I have to follow the W3Cs current

    > "best-practice"
    > > recommendations and go for stylesheets. Well, company guidelines dictate
    > > that I have to anyway !
    > >
    > > "Eliyahu Goldin" <> wrote in message
    > > news:eCe48Y$...
    > > > Thank you Kevin,
    > > >
    > > > I was patiently waiting for this.
    > > >
    > > > Eliyahu
    > > >
    > > > "Kevin Spencer" <> wrote in message
    > > > news:%...
    > > > > Put it into a table cell.
    > > > >
    > > > > --
    > > > > HTH,
    > > > > Kevin Spencer
    > > > > .Net Developer
    > > > > Microsoft MVP
    > > > > Big things are made up
    > > > > of lots of little things.
    > > > >
    > > > > "JezB" <> wrote in message
    > > > > news:#...
    > > > > > But that's exactly what I dont want - I want it only wide enough

    to
    > > fit
    > > > > its
    > > > > > contents.
    > > > > >
    > > > > > "Kevin Spencer" <> wrote in message
    > > > > > news:...
    > > > > > > 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" <> wrote in message
    > > > > > > news:...
    > > > > > > > Good idea! But that only seems to work for height, the width

    of
    > my
    > > > DIV
    > > > > > > seems
    > > > > > > > to default to the full browser width.
    > > > > > > >
    > > > > > > > "Kevin Spencer" <> wrote in message
    > > > > > > > news:...
    > > > > > > > > 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.
    > > > > > > > >
    > > > > > > > > "JezB" <> wrote in message
    > > > > > > > > news:...
    > > > > > > > > > I have a DIV whose contents varies in size according to

    > data.
    > > > How
    > > > > > can
    > > > > > > I
    > > > > > > > > size
    > > > > > > > > > the DIV precisely to fit it's contents ?
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > >
    > > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
    JezB, Jul 7, 2004
    #13
  14. 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

    "JezB" <> wrote in message
    news:e03%23k2$...
    > Ha ha - here we go again.
    >
    > There is some debate going on about tables vs css for handling page

    layouts.
    > For example :
    >
    > http://www.barry.pearson.name/articles/layout_tables/css_positioning.htm
    > vs
    > http://www.nypl.org/styleguide/css/guidelines.html
    >
    > I dont really have enough detailed knowledge to know what is the best way.
    > But being new to the arena I have to follow the W3Cs current

    "best-practice"
    > recommendations and go for stylesheets. Well, company guidelines dictate
    > that I have to anyway !
    >
    > "Eliyahu Goldin" <> wrote in message
    > news:eCe48Y$...
    > > Thank you Kevin,
    > >
    > > I was patiently waiting for this.
    > >
    > > Eliyahu
    > >
    > > "Kevin Spencer" <> wrote in message
    > > news:%...
    > > > Put it into a table cell.
    > > >
    > > > --
    > > > HTH,
    > > > Kevin Spencer
    > > > .Net Developer
    > > > Microsoft MVP
    > > > Big things are made up
    > > > of lots of little things.
    > > >
    > > > "JezB" <> wrote in message
    > > > news:#...
    > > > > But that's exactly what I dont want - I want it only wide enough to

    > fit
    > > > its
    > > > > contents.
    > > > >
    > > > > "Kevin Spencer" <> wrote in message
    > > > > news:...
    > > > > > 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" <> wrote in message
    > > > > > news:...
    > > > > > > Good idea! But that only seems to work for height, the width of

    my
    > > DIV
    > > > > > seems
    > > > > > > to default to the full browser width.
    > > > > > >
    > > > > > > "Kevin Spencer" <> wrote in message
    > > > > > > news:...
    > > > > > > > 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.
    > > > > > > >
    > > > > > > > "JezB" <> wrote in message
    > > > > > > > news:...
    > > > > > > > > I have a DIV whose contents varies in size according to

    data.
    > > How
    > > > > can
    > > > > > I
    > > > > > > > size
    > > > > > > > > the DIV precisely to fit it's contents ?
    > > > > > > > >
    > > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
    Eliyahu Goldin, Jul 7, 2004
    #14
  15. Patience is a virtue, Eliyahu!

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

    "Eliyahu Goldin" <> wrote in message
    news:eCe48Y$...
    > Thank you Kevin,
    >
    > I was patiently waiting for this.
    >
    > Eliyahu
    >
    > "Kevin Spencer" <> wrote in message
    > news:%...
    > > Put it into a table cell.
    > >
    > > --
    > > HTH,
    > > Kevin Spencer
    > > .Net Developer
    > > Microsoft MVP
    > > Big things are made up
    > > of lots of little things.
    > >
    > > "JezB" <> wrote in message
    > > news:#...
    > > > But that's exactly what I dont want - I want it only wide enough to

    fit
    > > its
    > > > contents.
    > > >
    > > > "Kevin Spencer" <> wrote in message
    > > > news:...
    > > > > 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" <> wrote in message
    > > > > news:...
    > > > > > Good idea! But that only seems to work for height, the width of my

    > DIV
    > > > > seems
    > > > > > to default to the full browser width.
    > > > > >
    > > > > > "Kevin Spencer" <> wrote in message
    > > > > > news:...
    > > > > > > 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.
    > > > > > >
    > > > > > > "JezB" <> wrote in message
    > > > > > > news:...
    > > > > > > > I have a DIV whose contents varies in size according to data.

    > How
    > > > can
    > > > > I
    > > > > > > size
    > > > > > > > the DIV precisely to fit it's contents ?
    > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
    Kevin Spencer, Jul 7, 2004
    #15
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gnarlodious
    Replies:
    4
    Views:
    17,551
    elizas
    May 5, 2010
  2. Piet
    Replies:
    0
    Views:
    503
  3. Cal Who
    Replies:
    2
    Views:
    402
    Cal Who
    Jun 1, 2010
  4. Cal Who
    Replies:
    1
    Views:
    913
    Cal Who
    Jun 2, 2010
  5. Berko
    Replies:
    4
    Views:
    83
    Berko
    Jun 27, 2006
Loading...

Share This Page