Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Stretch a DIV width to match content within...

Options
  • 07-08-2009 10:57am
    #1
    Moderators, Society & Culture Moderators Posts: 25,558 Mod ✭✭✭✭


    Hi guys,

    I want to have a DIV, of an unfixed width, so that it will stretch to display the content that appears within in. (In this case a video window with a large and small size).

    The video object is in the .playerBorder DIV, which sits within the .playerWrap DIV. The problem is

    (1) If I don't specify a width (as per below), the .playerBorder DIV stretches to 100% of the page regardless of what size object is in it.
    (2) If I specify a width, but allow overflow: visible, the overflow isn't centered like it needs to be.

    Any thoughts, etc, appreciated! :)

    [HTML]<div class="playerWrap">
    <div class="playerBorder">CONTENT THAT CHANGES WIDTH</div>
    </div>[/HTML]

    [HTML].playerWrap{
    margin-left: auto;
    margin-right: auto;
    margin-top: 50px;
    margin-bottom: 0px;
    text-align: center;
    background-color: #99FF33
    }


    .playerBorder {
    background-color: #b3b3b3;
    border-color: #000000;
    border-style: solid;
    border-top-width: 1px;
    border-right-width: 1px;
    border-bottom-width: 1px;
    border-left-width: 1px;
    padding: 0px;
    overflow: visible;
    margin-left: auto;
    margin-right: auto;
    }[/HTML]


Comments

  • Moderators, Society & Culture Moderators Posts: 25,558 Mod ✭✭✭✭Dades


    I had to use a table, btw. ;)


Advertisement