tags:

views:

25

answers:

1

I am styling a div that contains the main content of my web page. The header has it's own div and correctly spans the page 100%.

I added a margin-left:125px style to the main content div and now the right edge exceeds 100% of the browser width.

How do I compensate for the this? Thanks

+1  A: 

I'm not really sure if its what you are trying to do, but:

    <style type="text/css">
        #Header {
            background: red;
        }

        #Content {
            margin-left: 125px;
            background: green;
        }
    </style>
    <div id="Header">
        &nbsp;
    </div>
    <div id="Content">
        &nbsp;
    </div>

You don't need width:100%, because block level elements will automatically take all the width they can, unless specified otherwise.

x3ro
my sample is not like this.It is like so:<div id="Header"></div><div id="Content"></div>#content{margin-left:125px;}
ChiliYago
That doesn't change the fact that you just don't need width:100%, does it?
x3ro
Well something is making my content's right margin move beyond the browser width by the same value specified in the margin-left setting.
ChiliYago
Then post your whole code already... Guessing is not that much fun -.-
x3ro
You musn't mix width:100% with margin-left, or else the problem you mentioned will occur.
syockit