[SOLVED] Centralising a sub-wrap

This is a discussion on "[SOLVED] Centralising a sub-wrap" within the Web Page Design section. This forum, and the thread "[SOLVED] Centralising a sub-wrap are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Nov 6th, 2007, 12:47
Junior Member
Join Date: Nov 2007
Location: UK
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] Centralising a sub-wrap

Hi all,

Since Linda was kind enough to show me how to create a wrap using CSS so I don't need to use position. I have tried to create a sub wrap within the main wrap that will hold the Header, Content and Footer. The subwraps width wants to be 800px and centralised inside the main wrap. I've looked on the site and I've seen you all saying use:
HTML: Select all
margin: auto 0;
but when I use this nothing seems to happen. It maybe I've missed something so here is both the HTML code and CSS code

HTML: Select all
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel="stylesheet" type="text/css"href="test4.css" />
<title>Time and Date</title>
</head>
<body>
<div id="wrap">
    <div id="topbar">
       <div class="time">Name & Points</div>
       <div class="login">Date & Time</div>
    </div><!--end blackline div -->
    <div id="subwrap">Hello ALL</div>
    <div id="header">Header 
Image 
Here<br />
 Blah<br />
Blah<br />
Blah
  </div>
  <div id="content">Content of site goes in this div!<br />
    Blah<br />
    Blah<br />
    Blah<br />
</div>
    <div id="footer">Footer here!</div>
</div><!--end wrap div -->
</body>
</html>
</html>
HTML: Select all
/* ----- Body Configuration ----- */
body
 {
 margin: 0;
 background-color:#666666;
 }
/* ----- Wrap Configuration ----- */
#wrap
 {
 width: 100%;
 height: 100%;
 margin: 0 auto;
 }
#subwrap
 {
 width: 800px;
 margin: 0 auto;
 }
/* ----- Top Bar Configuration ----- */
#topbar
 {
 width: 100%;
 margin: 0 auto;
 padding: 2px 5px 2px 5px;
 margin-bottom: 15px;
 background: #000000;
 border-bottom: 1px solid #FFFFFF;
 font: 9px Arial, Helvetica, sans-serif;
 color: #FFFFFF;
 overflow: hidden;  
    }       
.time
 {
 width: 300px;
 float: left;
 text-align: left;
 }
.login
 {
 width: 300px;
 float: right;
 text-align: right;
 }
 
/* ----- Content Configuration ----- */
#header
 {
 width: 100%;
 margin: 0 auto;
 background: #990000;
 }    
#content {
    width: 100%;
    margin: 0 auto;
    background:#FFFFCC;
    }    
#footer {
    width: 100%;
    margin: 0 auto;
    background: #000000;
    }
Reply With Quote

  #2 (permalink)  
Old Nov 6th, 2007, 12:51
Highly Reputable Member
Join Date: Sep 2007
Age: 15
Posts: 717
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Centralising a sub-wrap

I take that you are trying to center all of your elements with margin:0 auto; I think the problem is that you have margin:0; set to the body in the css. Try removing it.
Last Blog Entry: Windows Vista vs. Mac Leopard (Nov 4th, 2007)
Reply With Quote
  #3 (permalink)  
Old Nov 6th, 2007, 12:52
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Centralising a sub-wrap

Quote:
Originally Posted by swagner View Post
I take that you are trying to center all of your elements with margin:0 auto; I think the problem is that you have margin:0; set to the body in the css. Try removing it.
margin: 0 in the body { } is fine. It's removing the default margins set by the browser.

Could you post a link please?
Reply With Quote
  #4 (permalink)  
Old Nov 6th, 2007, 12:55
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Centralising a sub-wrap

*sigh*

You have no Doctype. You are probably looking at this in IE6. Those two factors combined will destroy auto margins.

Add a Doctype, and validate your site.

Please upload your site (or page), and give us a link!
Reply With Quote
  #5 (permalink)  
Old Nov 6th, 2007, 12:58
Junior Member
Join Date: Nov 2007
Location: UK
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Centralising a sub-wrap

http://www.cipherpol.com/test4.htm This is the site, where it says "HELLO ALL" is the subwrap. Once I get that to be centered I was going to put the head, content and footer into it.
Reply With Quote
  #6 (permalink)  
Old Nov 6th, 2007, 13:00
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Centralising a sub-wrap

Like Mike said ... add a DOCTYPE first.
Reply With Quote
  #7 (permalink)  
Old Nov 6th, 2007, 13:04
Junior Member
Join Date: Nov 2007
Location: UK
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Centralising a sub-wrap

:S not to sound completely stupid hehe, since I'm at work I'm using Frontpage 2003 which is completely a waste of space. I have Dreamweaver CS3 at home which automatically puts the DOCTYPE in, were as frontpage it doesn't and I don't know how to hehe.

Also I'm using IE7.

Last edited by Madball; Nov 6th, 2007 at 13:15.
Reply With Quote
  #8 (permalink)  
Old Nov 6th, 2007, 13:18
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Centralising a sub-wrap

HTML is text. That's all. You can use notepad to add a doctype!

Testing your page confirms my prediction: the centring is working in Firefox, but not in IE6. All you have to do is add a doctype.

If you're not already testing in Firefox, you should be! When you test in Firefox, errors are (almost) always your own fault; when you test in IE, it's impossible to know whether you or the browser is to blame.

I advise against allowing any program to choose the doctype. Different doctypes have different uses, and Dreamweaver chooses a silly one by default (XHTML trans.). See my article on doctypes for more information.

Last edited by MikeHopley; Nov 6th, 2007 at 13:20.
Reply With Quote
  #9 (permalink)  
Old Nov 6th, 2007, 13:26
Junior Member
Join Date: Nov 2007
Location: UK
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Centralising a sub-wrap

OK I've got it working, but not 100%, the text has been aligned to the center of the:
HTML: Select all
<div id="subwrap">
but the actual div isn't centered on the screen, it is still aligned to the left. Am I doing something wrong there?

The DOCTYPE I added was:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" http://www.w3.org/TR/html4/loose.dtd>

EDIT!!!! OK it is working, my fault sorry. When I look at it in IE7 it is fine, but when I look at it in Frontpage 2003 editing area it is still aligned to the left.

Last edited by Madball; Nov 6th, 2007 at 13:29.
Reply With Quote
  #10 (permalink)  
Old Nov 6th, 2007, 13:33
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Centralising a sub-wrap

Well done!

Your <div> is centred correctly. I don't see the problem. Try reducing the width of the <div>, and adding a background colour, so that you can observe it's behaviour more easily.
Reply With Quote
  #11 (permalink)  
Old Nov 6th, 2007, 14:43
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Centralising a sub-wrap

Quote:
Originally Posted by Madball View Post
EDIT!!!! OK it is working, my fault sorry. When I look at it in IE7 it is fine, but when I look at it in Frontpage 2003 editing area it is still aligned to the left.
ALWAYS view/test your site in the proper browsers (IE6, IE7, FF, Opera and Safari) NEVER in your editors' preview area

Glad to see you got it working
Reply With Quote
Reply

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
How to text wrap? Quetzal Web Page Design 9 Jun 3rd, 2008 18:58
Centralising my site danny322 Web Page Design 16 Nov 5th, 2007 16:12
div wrap not working on IE pc jillcary Web Page Design 5 Jul 19th, 2007 17:33
Div outside wrap issue timmytots Web Page Design 5 Oct 14th, 2006 23:28
How to wrap text around a div AdRock Web Page Design 6 Sep 5th, 2006 19:02


All times are GMT. The time now is 03:56.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs 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 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43