HighDots Forums  

Re: Div width 100% with margin

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss Re: Div width 100% with margin in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
David Dorward
 
Posts: n/a

Default Re: Div width 100% with margin - 09-01-2003 , 12:02 PM






Tony Benham wrote:

Quote:
I want to be able to have a div which occupies the full width of the
browser window, but taking into account margin for that div. I've tried
using width: 100% ; margin 1 em ; properties for the div, but the right
hand edge of the div insists on touching the right hand edge of the
browser window even though the margin should be 1em. It seems to do this
both in netscape 7.1, and ie6. Am I trying to do something that cannot be
done ?
Remember that "width" is "width of content" not "width of content + padding
+ border + margin".

{
margin: 1em;
padding: 0;
border-width: 0;
width: auto;
}


--
David Dorward http://dorward.me.uk/


Reply With Quote
  #2  
Old   
Tony Benham
 
Posts: n/a

Default Re: Div width 100% with margin - 09-01-2003 , 01:02 PM






"David Dorward" <dorward (AT) yahoo (DOT) com> wrote

Quote:
Tony Benham wrote:

I want to be able to have a div which occupies the full width of the
browser window, but taking into account margin for that div. I've tried
using width: 100% ; margin 1 em ; properties for the div, but the right
hand edge of the div insists on touching the right hand edge of the
browser window even though the margin should be 1em. It seems to do this
both in netscape 7.1, and ie6. Am I trying to do something that cannot
be
done ?

Remember that "width" is "width of content" not "width of content +
padding
+ border + margin".

{
margin: 1em;
padding: 0;
border-width: 0;
width: auto;
}

I missed off one piece of info, the content in some cases is not going to be
the width of the browser window, but I still would like the div to expand to
the width of the browser window (minus the margin at lh/rh/top/bottom edges)
? I guess it is a 'fluid box' that should fill the width of the browser
window minus the margin whatever the width of the content ?
However even when the content is large enough to fill the width of the
browser the margin is still not being applied as I explained previously, so
the div edge touches the browser window edge without a margin.
Regards
Tony B




Reply With Quote
  #3  
Old   
David Dorward
 
Posts: n/a

Default Re: Div width 100% with margin - 09-01-2003 , 07:42 PM



Brian wrote:

Quote:
Tony Benham wrote:

the content in some cases is not going to be the width of the
browser window, but I still would like the div to expand to the
width of the browser window (minus the margin at lh/rh/top/bottom
edges) ?

That happens normally with block level boxes, doesn't it?
Yes


--
David Dorward http://dorward.me.uk/


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.