iEntry 10th Anniversary Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > HTML, XHTML and CSS

Reply
 
LinkBack Thread Tools
Old April 16th, 2008, 05:22 AM   #1
New Member
 

Join Date: Apr 2008
Location: Sheffield
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 mpnuttall is on a distinguished road
Question Vertical centering - please help!

Hi there

I really hope someone can help with this as I'm beginning to despair.

I'm somewhat of a CSS (and HTML for that matter) novice, and have been trying to understand enough to build my site.

I've got most things sorted and looking reasonable, but can't get my page content (not the header image or menu though) to vertically center. You can see what I mean here:

www.conkerphotography.co.uk/about.htm

It looks okay on a 1024 wide or smaller monitor, but looks very unbalanced on larger ones.

I've tried all sorts of ideas from various sites but think my lack of understanding of the basics is holding me back.

I've pasted the page code for the above link below, and also the code from my 'maincss.css' style sheet which informs most of the layout. Can someone please advise what i need to add and where?

Any support would be greatly appreciated.

Many thanks, mpnuttall

Page code

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>About Conker Photography</title>
<link href="main_css.css" rel="stylesheet" type="text/css" />
<link href="menu.css" rel="stylesheet" type="text/css" />
<style type="text/css">
body { margin:0; padding:0; position:absolute; height:100%; background-color:c3d43a; width:100%; } </style>
</head>

<body><div class="full"></div>
    <div class="normal">
    <div id="header"><img src="http://www.webforumz.com/images/new_header.jpg" alt="Header" width="529" height="65" align="top"/></div>


    <div id="navigation">

    <h2><ul id="menu">
    <li><a href="index.html">Home</a></li>
    <li><a href="about.htm">About</a></li>
    <li><a href="gallery2.htm">Gallery</a></li>
    <li><a href="ordering.htm">Ordering</a></li>
    <li><a href="contact.htm">Contact</a></li>
    </ul>
    </h2>
    </div>


  
      <div id="main">
    <FONT SIZE=1 color=#888888>
      <FONT SIZE=1 color=#c3d43a><B>What's with the name?</B></FONT><BR><FONT SIZE=1 color=#888888>

Conkers are great. They’re green, spiky, and make for one of the best childhood games ever. And it’s a great word too – just         try saying it out loud. Go on, no-ones watching…
    <BR><BR>

    <FONT SIZE=1 color=#c3d43a><B>Tell me a bit more about the photographs on the site</B></FONT><BR><FONT SIZE=1 color=#888888>

All the photos on this site are taken by Mark Nuttall, and were mostly taken in the Peak District, England. Photos from other locations do raise their heads here too, and if you have a question about a particular photo then just <a href="contact.htm">ask</a>. <P>New photos are added to the site regularly so stick it in your bookmarks/favourites and be sure to check back every once in a while: 
<script language="JavaScript1.2" type="text/javascript">
     function CreateBookmarkLink() {
        title="Conker Photography"; 
        url="http://www.conkerphotography.co.uk";
        if (window.sidebar) { // Mozilla Firefox Bookmark
            window.sidebar.addPanel(title, url,"");
        } else if( window.external ) { // IE Favorite
            window.external.AddFavorite( url, title); }
        else if(window.opera && window.print) { // Opera Hotlist
            return true; }
     }

     if (window.external) {
      document.write('<a href="javascript:CreateBookmarkLink()");"> bookmark/add to favourites now.</a>'); 
      } else  if (window.sidebar) {
      document.write('<a href="javascript:CreateBookmarkLink()");"> bookmark/add to favourites now.</a>'); 
     } else if (window.opera && window.print) {    
       document.write('<a href="javascript:CreateBookmarkLink()");"> bookmark/add to favourites now.</a>');
     } 
</script>


    <BR><BR>
    <FONT SIZE=1 color=#c3d43a><B>But wait - I still have more questions!</B></FONT><BR><FONT SIZE=1 color=#888888>

No problem, just <a href="contact.htm">get in touch</a> and you’ll get a reply faster than you can say conker…or at least within a day or two.
    </p>
      <p>Thanks for visiting.</p>
      <p>&nbsp;</p>

    </div>
</div>
</body>
</html>


Main CSS

/* Generic Selectors */

body {
    font-family: "Verdana", Arial, Helvetica, sans-serif;
    font-size: 14px;
    color: ##999999;
    background-color: #c3d43a;
    
}



h1 {
    font-family: "Verdana", Arial, Helvetica, sans-serif;
    font-size: 18px;
    font-weight: lighter;
    color: #999999;
}

h2 {
    font-family: "Verdana", Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-weight: lighter;
    color: #999999;
}

 

/**************** Pseudo classes ****************/

a:link {
    color: #666666;
}

li a:link {
    color: #666666;
    text-decoration: none;

}

a:visited {

color: #666666;

text-decoration: underline;


}

li a:visited {

color: #669933;

text-decoration: none;


}

a:hover {
    color: #c3d43a;
    padding-bottom: 5px;
    font-weight: normal;
    text-decoration: underline;
}

li a:hover {
    display: block;
    color: #FFFFFF;
    padding-bottom: 5px;
    font-weight: normal;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: #999999;
}

a:active {

color: rgb(255, 0, 102);



}


.full { 
    position:absolute; 
    top:0; 
    left:9%; 
    width:80%; 
    height:100%; 
    background-color:white; 
    padding:0 1em; 
} 

.normal { 
    position:absolute; top:0; 
    left:9%; 
    width:80%; 
    height:auto; 
    background-color:white; 
    padding:0 1em; 
} 


/************************* ID's *************************/

#navigation {
    z-index: 10;
    width: 350px;
    height: 30px;
    font-weight: lighter;
    margin-top: 0px;
    margin-left: auto;
    margin-right: auto;
    font-family: "Verdana", Arial, Helvetica, sans-serif;
}

#outer {
    width: 70%;
    background-color:#FFFFFF;
    margin-left: auto;
        margin-right: auto;
        padding: 0px;
}
#header {
       width: 529px;
    margin-top: 10px;
    margin-left: auto;
    margin-right: auto;
}

#main {
    width: 80%;
    background-color:#FFFFFF;
    margin-top: auto;
    margin-bottom: auto;
    margin-left: auto;
    margin-right: auto;
    padding: 0px;
}

#form {
    width: 80%;
    background-color:#FFFFFF;
    margin-top: 20px;
    margin-bottom: 10px;
    margin-left: auto;
    margin-right: auto;
    padding: 0px;
}

#paypal {
    width: 37%;
    background-color:#FFFFFF;
    margin-top: 0px;
    margin-bottom: 0px;
    margin-left: auto;
    margin-right: auto;
    padding: 0px;
}

#centerDoc {
    position: relative;
    z-index: 15;
    width: 70%;
    margin-top: 5px;
    margin-left: auto;
    margin-right: auto;

Last edited by saltedm8; April 16th, 2008 at 06:54 AM.. Reason: added [code] tags
mpnuttall is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old April 16th, 2008, 05:48 AM   #2
New Member
 

Join Date: Apr 2008
Location: Sheffield
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 mpnuttall is on a distinguished road
Re: Vertical centering - please help!

Forgot to say, the height of each pages content (i.e. the bit in the div="main" section) varies, so I can't use fixed widths and heights for these elements and need the positioning to adjust in the same way the width does when the browser window is resized.
mpnuttall is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old April 16th, 2008, 06:05 AM   #3
Reputable Member
 

Join Date: Jun 2007
Location: uk
Posts: 461
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 dab42pat is on a distinguished road
Re: Vertical centering - please help!

Hi

I have treied on various resolutions and cant see your problem.

The page you mention has this.

HTML Code:
 body { margin:0; padding:0; position:absolute; height:100%; background-color:c3d43a; width:100%; }
Try this instead.

HTML Code:
 body { margin:0 auto;  height:100%; background-color:c3d43a; width:100%; }
I havent tested it but it might work, also check out http://browsershots.org/ to see how it looks in various browsers and resolutions.

HTH

Pat
dab42pat is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old April 16th, 2008, 06:47 AM   #4
New Member
 

Join Date: Apr 2008
Location: Sheffield
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 mpnuttall is on a distinguished road
Re: Vertical centering - please help!

Thanks for the reply Pat. I tried your code, though it hasn't changed anything. Maybe I wasn't clear about what i'm looking to achieve - I don't have a 'problem' as such (in so far as the layout I have works) but wanted to change it from this:


to this:



I.E. the content 'floats' in the centre of the screen regardless of window size/resolution. Is this possible?

Thanks again, mpnutall
mpnuttall is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old April 16th, 2008, 07:02 AM   #5
Most Reputable Member
SuperMember
 

Join Date: Nov 2005
Location: here
Age: 28
Posts: 1,533
Thanks: 1
Thanked 11 Times in 11 Posts
Rep Altering Power: 0 saltedm8 will become famous soon enough saltedm8 will become famous soon enough
Re: Vertical centering - please help!

this might help you http://www.wpdfd.com/editorial/thebox/deadcentre4.html
saltedm8 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old April 16th, 2008, 07:05 AM   #6
Reputable Member
 

Join Date: Jun 2007
Location: uk
Posts: 461
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 dab42pat is on a distinguished road
Re: Vertical centering - please help!

In your #main. give your margin-top something like 150px. That should remain constant.
dab42pat is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old April 16th, 2008, 07:38 AM   #7
New Member
 

Join Date: Apr 2008
Location: Sheffield
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 mpnuttall is on a distinguished road
Re: Vertical centering - please help!

Thanks both.

Pat - I don't actually want it to remain a constant distance from the top, I want it to stay centred as the page is resized.

saltedm8 - I'll give this a try. It looks like it might achieve what i want, but as I said I'm a novice and think I might struggle to integrate it in to my existing code :oS

Thanks again, mpnuttall
mpnuttall is offline  
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

Bookmarks

Tags
align , center , vertical


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
CSS Vertical Menu. Can someone help? CoolNeb HTML, XHTML and CSS 3 July 16th, 2007 02:00 PM
Div Vertical Align jwalker80 HTML, XHTML and CSS 5 January 30th, 2007 07:34 PM
vertical centering woes gwx03 HTML, XHTML and CSS 6 June 5th, 2004 05:43 PM
Tip : Vertical and Horizontal Centering - Solved! gwx03 HTML, XHTML and CSS 0 December 15th, 2003 02:11 AM
Vertical Centering in CSS gwx03 HTML, XHTML and CSS 1 December 5th, 2003 11:36 AM


Search Engine Optimization by vBSEO 3.2.0 RC8