SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot PixelPaul's Avatar
    Join Date
    Nov 2003
    Location
    Wisconsin, USA
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    variable width div

    Is there a way in CSS to create a variable width div? I have a div that will hold dynamically generated content. It may have 2 columns of images or it might have 4 columns of images. Is there a way to get it to resize to the width of it's contents? If I do not specify an exact width, it sizes to the width of the browser viewport, regardless of it's contents. Any ideas?

  2. #2
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,564
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    You could make the width shrink to fit by either making it display:inline-block, display:table-cell; or floating it . Of course, each has the downfalls and other catering issues (which I'm assuming you already know how )

    You could set a min/max width on the container of those columns..but ultimately it isn't that great for a dynamic situation just because you would have to manually specify how many columns..a multi column module is available in CSS3 though support is flimsy with only vendor extension testing in webkit/gecko

    I hope I helped and I didn't sound like a rambling idiot (work+college semester finals=my brain dead )
    Twitter-@Ryan_Reese09
    http://www.ryanreese.us -Always looking for web design/development work


Bookmarks

Posting Permissions

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