Results 1 to 3 of 3

Thread: DIV positioning

  1. #1

    Thread Starter
    Fanatic Member davebat's Avatar
    Join Date
    Dec 2002
    Posts
    727

    DIV positioning

    could anyone point me in the right direction, Im trying to create a website with no tables, so am using divs and CSS. I'd like a 760 px div in the center for small browser windows, with a a div on the right and one on the left that take up the rest of the space equally. Does anyone know how to do this?

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

  3. #3
    Hyperactive Member BramVandenbon's Avatar
    Join Date
    Jan 2002
    Location
    Belgium
    Posts
    502

    Re: DIV positioning

    I don't like W3C documentation. Always way too complicated for what it actually is.

    So I'll save you 2 hours of misery:


    First you need a div-tag and give it a name. Imho there's only one div tag needed. (If you do want multiple div tags then post a reply, I'll see what I can do)

    Next make a STYLE CSS block and put a reference to that name. There you need to specify the width and ofcourse all kind of other stuff like font and colour, etc...

    After that you could set the background colour by specifying the BODY element in the Style block.

    And if you want the whole thing to be centered I would just wrap some CENTER tags around the div tag.

    HTML Code:
    <style>
    .test{
    width:720px;
    background-color:#FF0000;
    }
    BODY{
    background-color:#FF4444;
    }
    </style>
    
    
    <BODY>
    <CENTER>
    <DIV class="test">
      Content and text goes here
    </DIV>
    </CENTER>
    </BODY>
    Another (bad imho) way to do it:

    HTML Code:
    .test{
    position: absolute;
    left: ...;
    width: ...;
    z-index: ...;
    }
    That would make a margin at the left and right but wouldn't really help people with small resolution. Cause also for them it would leave a border. So you would end up writing some javascript around it I guess?

    Same goes for:
    HTML Code:
    .test{
    margin-left: ...;
    margin-right: ...;
    }
    ____________________________________________

    Please rate my messages. Thank you!
    ____________________________________________
    Bram Vandenbon
    http://www.bramvandenbon.com

Posting Permissions

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



Click Here to Expand Forum to Full Width