collapsing page margins

This is a discussion on "collapsing page margins" within the Starting Out section. This forum, and the thread "collapsing page margins are both part of the Design Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Design Your Website > Starting Out

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Jun 20th, 2007, 08:51
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
collapsing page margins

Hi,

I've looked around the site for this topic but I can't find it anywhere.

Sometimes I like to create a page/site which doesn't use up all of the horizontal space at a resolution of 1024x768. It has an equal margin on both sides. I would like to learn how to do something that I often see on the web.

Say you have a browser window which is not maximised but it almost fills the screen. Grab hold of the right hand border and gradually narrow the window. The left hand margin disappears until the left of the window hits the centrally placed content, as you continue to narrow the window the left margin begins to dissapear. Only once both margins have gone do you get a horizontal scrollbar. I think this is a really good bit of functionality but I have no idea how it is done.

Could anyone help me or push me in the direction of a resource that can?

Many thanks

Paul
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Jun 20th, 2007, 10:18
Most Reputable Member
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: collapsing page margins

I also love these flexible layouts I can teach you how to create them, but first I want to check that I understand your goals. Take a look at this site that I made, and tell me whether it's the sort of collapsing margins that you want:

http://www.badmintonbible.com

Would you be happy with those kinds of collapsing margins?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Jun 20th, 2007, 10:50
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Re: collapsing page margins

Hi Mike,

That is a great site but it isn't quite what I was meaning. What I was wanting is much simpler, I hope . The main content in the center wouldn't change, fixed scale but as you move the window in first the margin to the right of the main content would reduce until gone then the left margin would reduce until gone leaving just the main content. Only if the window was pulled narrower than the main content would this introduce the horizontal scrollbar. With a page like that I normally create the space to the right of the content would reduce until the main content was reached, at this point the scrollbar appears but as I reduce the width even further the content disappears before the left margin, I want both margins to go first.

Thanks for showing me the site.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Jun 20th, 2007, 11:09
Most Reputable Member
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: collapsing page margins

I'm not sure how to make one margin disappear first (nor is this desirable, usually). But I can show you how to make the margins collapse together.

First, put your content in a containing <div id="content">.

Second, use CSS to set your <div> width in either px or em. Using % won't work. Third, centre your site by applying margin: 0 auto; to the <div>

Code: Select all
div#content {
width: 700px;
margin: 0 auto;
}
Hope that helps
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Jun 20th, 2007, 11:12
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Re: collapsing page margins

Thanks Mike really appreciate that. I will try it out.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Jun 20th, 2007, 11:38
Most Reputable Member
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: collapsing page margins

Quote:
Originally Posted by aflacduck View Post
Thanks Mike really appreciate that. I will try it out.
Let me know how you get on!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Jun 21st, 2007, 11:28
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Re: collapsing page margins

That worked a treat Mike and such small piece of code. The site is not on the server yet.

Thanks for your help, really appreciate your time.

Paul Rich
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Jun 21st, 2007, 12:09
Most Reputable Member
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: collapsing page margins

Quote:
Originally Posted by aflacduck View Post
That worked a treat Mike and such small piece of code. The site is not on the server yet.

Thanks for your help, really appreciate your time.

Paul Rich
Excellent. Glad to help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Jun 21st, 2007, 12:20
Most Reputable Member
Join Date: May 2006
Location: North West, UK
Age: 22
Posts: 1,173
Thanks: 0
Thanked 0 Times in 0 Posts
Re: collapsing page margins

For older browsers use

Code: Select all
body {
    text-align: center;
}

div#container {
    width: 700px;
    margin: 0 auto;
    text-align: left;
}
The text-align:center; just centres the content for older browsers and the text-align: left; makes sure that your text doesn't all centre as well. This isn't totally essentail but it's a good idea.

Pete.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old Jun 24th, 2007, 08:38
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Re: collapsing page margins

Thanks pa007,

Which older browsers would you use that for, ie5x? or are you including ie6 in that. I'm always a bit confused as to what to test with. I have firefox and ie7 on my desktop and ie6 on my laptop. This means I pretty much ignore ie5x but I wouldn't think these days that would be too much of an issue. I know it's important to be as inclusive as possible when designing but you have to be practicle too.

Appreciate your help.

Paul R
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #11  
Old Jun 24th, 2007, 13:46
Most Reputable Member
Join Date: May 2006
Location: North West, UK
Age: 22
Posts: 1,173
Thanks: 0
Thanked 0 Times in 0 Posts
Re: collapsing page margins

If I remember rightly that is for ie6. ie7 is ok I think, though I wouldn't know as I always include the extra code. But it's still something worth bothering with, definitely.

Glad I could help.

Pete.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #12  
Old Jul 9th, 2007, 17:00
Most Reputable Member
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: collapsing page margins

Quote:
Originally Posted by pa007 View Post
If I remember rightly that is for ie6. ie7 is ok I think, though I wouldn't know as I always include the extra code. But it's still something worth bothering with, definitely.

Glad I could help.

Pete.
It's only necessary for IE6 if you trigger quirks mode.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #13  
Old Jul 9th, 2007, 18:35
Most Reputable Member
Join Date: May 2006
Location: North West, UK
Age: 22
Posts: 1,173
Thanks: 0
Thanked 0 Times in 0 Posts
Re: collapsing page margins

Ah so that's why. I always did wonder. I basically just did it because when I made my first fixed width centred layout with css, I was told to. I won't anymore, thanks for the heads up.

Pete.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #14  
Old Jul 9th, 2007, 18:53
Most Reputable Member
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: collapsing page margins

Quote:
Originally Posted by pa007 View Post
Ah so that's why. I always did wonder. I basically just did it because when I made my first fixed width centred layout with css, I was told to. I won't anymore, thanks for the heads up.

Pete.
Don't forget that IE5 will need it.

IE6 rendering in quirks mode = IE5 rendering.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #15  
Old Jul 9th, 2007, 19:26
Most Reputable Member
Join Date: May 2006
Location: North West, UK
Age: 22
Posts: 1,173
Thanks: 0
Thanked 0 Times in 0 Posts
Re: collapsing page margins

Well, I must admit IE 5 only gets a brief look as regards cross browser compatibility. Depends on the project but I never go too far out of my way to support IE 5, that said I've never had any major problems. I just wish they would ban IE 5, it would make life easier.

Pete.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #16  
Old Jul 9th, 2007, 19:31
Most Reputable Member
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: collapsing page margins

Quote:
Originally Posted by pa007 View Post
Well, I must admit IE 5 only gets a brief look as regards cross browser compatibility. Depends on the project but I never go too far out of my way to support IE 5, that said I've never had any major problems. I just wish they would ban IE 5, it would make life easier.

Pete.
Yep, much the same for me. I give it about 5 minutes, and only because conditional comments are clean It's just not worth much time given its tiny and diminishing market share.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
margin

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Margins in IE are different than Firefox KiwiTaicho Web Page Design 3 Sep 28th, 2007 14:57
Margins need fixing notagz1 Starting Out 9 May 28th, 2007 14:03
What's up with margins and padding in IE? Donny Bahama Web Page Design 41 Apr 19th, 2007 10:04
ff margins Dapandyman Web Page Design 10 Feb 12th, 2007 23:03
body margins benbacardi Web Page Design 2 Apr 10th, 2004 14:51


All times are GMT. The time now is 16:22.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16