Results 1 to 2 of 2

Thread: Expandable divs

  1. #1
    Join Date
    Mar 2008
    Location
    Iowa
    Posts
    103

    Expandable divs

    I'm trying to create a div that will size its self to fit the content in it. But I'm not making it a square div, it's going to have rounded edges. So I'm thinking I need to make 3 divs, the middle one being square, and being the one that can expand. then there would be one on top and one on bottom that would give the illusion of a singe, round-edged container. The only problem is that I can't figure out how to position the two divs to make them flush with the middle one. Any ideas? how do most designers do expanding divs like this?
    Radiant Web Design

    Music Reviews at my blog: Life By The Drop

  2. #2
    Join Date
    Feb 2006
    Location
    Salisbury UK
    Posts
    4,332
    Divs normally go onto a new line, so if you code three divs, they should be on top of one another. Make sure they have no top or bottom margins or padding.

    <div id="top">&nbsp;</div>
    <div id="middle"><p>Content here</p></div>
    <div id="bottom">&nbsp;</div>

    CSS something like:-
    #top, #middle, #bottom { margin: 0; padding: 0; }
    #top { background-image: url(top.jpg); width: ??px; height: ??px; }
    #middle { width: ??px; }
    #bottom { background-image: url(bottom.jpg); width: ??px; height: ??px; }

    This assumes that the top.jpg and bottom.jpg have a fixed width and rounded corners (one is normally the other saved upside down).

    Quite often a containing div is created around all three divs so that the containing div can be accurately positioned and hold together the inner divs.
    Code downloaded to my PC will be deleted in due course.
    WIN7; IE9, Firefox, Opera, Chrome and Safari for Windows; screen resolution usually 1366*768.
    Also IE6 on W98 with 800*600 and IE8 on Vista 1440*900.

Posting Permissions

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