Div Not Filling Page?

Discussion in 'HTML' started by nickolas80@gmail.com, Sep 28, 2005.

  1. Guest

    I have a DIV which I want to completely go from one side of the page to
    the other, with not whitespace or margins. I can not seem to get it to
    work, it is flush on the left, but leaves about 15px of whitespace on
    the right side.

    Here is my CSS:

    #MidBar {
    position: absolute;
    height: 50px;
    width: 100%;
    left: 0px;
    top: 110px;
    background-color: #0066CC;
    right: 0px;
    }

    and my div:

    <div class="MidBar" id="MidBar"></div>


    any suggestions?
    , Sep 28, 2005
    #1
    1. Advertising

  2. Els Guest

    wrote:

    > I have a DIV which I want to completely go from one side of the page to
    > the other, with not whitespace or margins. I can not seem to get it to
    > work, it is flush on the left, but leaves about 15px of whitespace on
    > the right side.
    >
    > Here is my CSS:
    >
    > #MidBar {
    > position: absolute;
    > height: 50px;
    > width: 100%;
    > left: 0px;
    > top: 110px;
    > background-color: #0066CC;
    > right: 0px;
    > }
    >
    > and my div:
    >
    > <div class="MidBar" id="MidBar"></div>
    >
    > any suggestions?


    Yes, I have two.
    One: leave out the width, and the 'right' property. Any div by default
    automagically stretches to 100% of what's the available width for it.
    Two: the 15px space is probably the padding or margin on <html> or
    <body>.
    Add this to your styles:
    html,body{margin:0;padding:0;}
    and see if that helps. If it doesn't, you'll need to show an actual
    example of your problem, for further investigation :)

    (and Three: I hope this div isn't meant to have text in it, and also
    doesn't have text above it)

    --
    Els http://locusmeus.com/
    Sonhos vem. Sonhos vão. O resto é imperfeito.
    - Renato Russo -
    Els, Sep 28, 2005
    #2
    1. Advertising

  3. Els wrote:
    > Any div by default automagically stretches to 100% of what's the
    > available width for it.


    Not when absolute positioning is applied.
    Leif K-Brooks, Sep 28, 2005
    #3
  4. Els Guest

    Leif K-Brooks wrote:

    > Els wrote:
    >> Any div by default automagically stretches to 100% of what's the
    >> available width for it.

    >
    > Not when absolute positioning is applied.


    You're right, didn't realize that.

    --
    Els http://locusmeus.com/
    Sonhos vem. Sonhos vão. O resto é imperfeito.
    - Renato Russo -
    Els, Sep 28, 2005
    #4
  5. Neredbojias Guest

    With neither quill nor qualm, quothed:

    > I have a DIV which I want to completely go from one side of the page to
    > the other, with not whitespace or margins. I can not seem to get it to
    > work, it is flush on the left, but leaves about 15px of whitespace on
    > the right side.
    >
    > Here is my CSS:
    >
    > #MidBar {
    > position: absolute;
    > height: 50px;
    > width: 100%;
    > left: 0px;
    > top: 110px;
    > background-color: #0066CC;
    > right: 0px;
    > }
    >
    > and my div:
    >
    > <div class="MidBar" id="MidBar"></div>
    >
    >
    > any suggestions?


    Did you check in more than 1 browser and see the same effect? Els
    suggestion of setting the margins and padding to 0 is a must, but IE can
    react strangely to some css.

    --
    Neredbojias
    Contrary to popular belief, it is believable.
    Neredbojias, Sep 28, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?UTF-8?B?TWFydGluIFDDtnBwaW5n?=

    div filling the whole page

    =?UTF-8?B?TWFydGluIFDDtnBwaW5n?=, Aug 14, 2005, in forum: HTML
    Replies:
    0
    Views:
    575
    =?UTF-8?B?TWFydGluIFDDtnBwaW5n?=
    Aug 14, 2005
  2. John Dalberg
    Replies:
    3
    Views:
    550
    Ben C
    Oct 18, 2006
  3. rowe_newsgroups

    Center Div Not Filling Height

    rowe_newsgroups, Jun 20, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    502
    bruce barker
    Jun 20, 2007
  4. Mohsen Pahlevanzadeh
    Replies:
    0
    Views:
    112
    Mohsen Pahlevanzadeh
    Sep 9, 2013
  5. MRAB
    Replies:
    0
    Views:
    111
Loading...

Share This Page