Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Looking for CSS container element that terminates like a table cell

    I'm looking for a CSS element that behaves like a table, where the size of the container will always be just big enough to surround the data inside, and will grow or shrink based on the content inside without having to specify any widths or heights.

    A div (with a border) with no width specified will go on forever horizontally. A table (with a border) with no width will stop as soon as the data inside ends.

    Is there a way to simulate this table behavior using CSS?

    Thanks

  • #2
    Senior Coder
    Join Date
    Jan 2005
    Location
    Memphis, TN
    Posts
    1,791
    Thanks
    8
    Thanked 131 Times in 129 Posts
    well, a
    Code:
    <span>
    will do that. What your looking for is an inline element. divs, being block level will always be 100% as wide as thier container unless told otherwise.
    Stop making things so hard on yourself.
    i is tugbucket :: help raise tugburg :: Whitehaven Kiwanis

  • #3
    Regular Coder
    Join Date
    Dec 2002
    Location
    Minneapolis, MN
    Posts
    208
    Thanks
    0
    Thanked 1 Time in 1 Post
    Not sure, but what are you doing that you can't use a table?
    anthony

  • #4
    Regular Coder
    Join Date
    Dec 2002
    Location
    Minneapolis, MN
    Posts
    208
    Thanks
    0
    Thanked 1 Time in 1 Post
    Quote Originally Posted by harbingerOTV View Post
    well, a
    Code:
    <span>
    will do that. What your looking for is an inline element. divs, being block level will always be 100% as wide as thier container unless told otherwise.
    Within a TD if you put a BR then the box drops to contain the text, a span will break.
    anthony

  • #5
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I can use a table, but am trying experience that wonderful (or not so) world of pure css.

    It looks like "display:table" "display:table-cell" "display:table-row", is what I need to get multiple rows to line up nicely, but IE6 and 7 (surprisingly) don't support any of those attributes, so there is no point in using them if 90% of the world can't see them. I'll just use a table.

    Thanks


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •