/    Sign up×
Community /Pin to ProfileBookmark

Grow/shrink div to size of contents?

I have a 15-column table inside a div (inside other divs). When I increase the font size in the browser, the table gets bigger but the box enclosing it doesn’t, so the table eventually breaks out of the box.

I don’t seem to be able to set the width of the box to auto or it spans the entire page.

[CODE].container {
position: relative;
margin: 0 auto;
width: 800px; (can’t be auto or it snaps to edges of page)
height: auto;
}

.content_outer_table { background: #000000;; position: relative; padding: 20px; }
.content_inner_table { background: #ffffff; border: 1px solid #333333; padding: 20px; }[/CODE]

The page is simplicity itself:

[CODE]<div class=”container”>
<div class=”content_outer_table”>
<div class=”content_inner_table”><!–table goes here–></div>
</div>
</div>[/CODE]

Can I have the divs “suck in” to the size of the content, or expand (horizontally) as the content grows?

  • Bob
  • to post a comment
    CSS

    1 Comments(s)

    Copy linkTweet thisAlerts:
    @toicontienJul 06.2005 — The only way to do that is to float the DIV or position it absolutely.
    ×

    Success!

    Help @bunner_bob spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.28,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...