centering help please

This is a discussion on "centering help please" within the Web Page Design section. This forum, and the thread "centering help please 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 Aug 2nd, 2007, 08:52
Reputable Member
Join Date: Jul 2007
Location: UK, Essex
Age: 21
Posts: 172
Thanks: 0
Thanked 1 Time in 1 Post
centering help please

Hey All,

I have a problem, I am attempt to design my first tabless layout which seems to be giving me all sorts of problems, I am currently atteptimg to place the part where it has "Destination", "Destination", "Destination", etc at the bottom of the layout: http://www.cheep-flights.com/
With this I want it to be in the center of the layout but everytime I change the float attribute to center it completely ruins the layout.

Here is my HTML code
Code: Select all
<div class="desttable">
<ul>
<li><a href="">DESTINATION</a></li>
<li><a href="">DESTINATION</a></li>
<li><a href="">DESTINATION</a></li>
<li><a href="">DESTINATION</a></li>
<li><a href="">DESTINATION</a></li>
</ul>
</div>
Here is my CSS code
Code: Select all
.desttable{
    position: relative;
    display: block;
    height: 20px;
    font-family: Arial,Verdana,Helvitica,sans-serif;
    font-size: 10px;
    font-weight: bold;
    padding: 5px;
}

.desttable ul{
    margin: 0;
    padding: 0;
    list-style-type: none;
    width: auto;
}

.desttable ul li{
    display: block;
    float: left;
    border: 1px solid #000;
}

.desttable ul li a{
    display: block;
    float: left;
    color: #0096ff;
    text-decoration: none;
    padding: 1px 10px 0px 10px;
    height: 18px;
}

.desttable ul li a:hover{
    text-decoration: underline;
    color: #000000;
}
Any help would be most appreciated

Thanks
Wayne

Last edited by Lchad; Aug 2nd, 2007 at 11:06. Reason: added code tags for easier viewing
Reply With Quote

  #2 (permalink)  
Old Aug 2nd, 2007, 09:06
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: centering help please

Quote:
Originally Posted by RZX Developer View Post
everytime I change the float attribute to center it completely ruins the layout.
There is no float: center;. Float takes the values "left", "right", or "none" (the default).

"Float: center" is invalid CSS that will never work.

To centre a <div>, or other block-level element, use the CSS "margin: 0 auto;"
Reply With Quote
  #3 (permalink)  
Old Aug 2nd, 2007, 09:10
Reputable Member
Join Date: Jul 2007
Location: UK, Essex
Age: 21
Posts: 172
Thanks: 0
Thanked 1 Time in 1 Post
Re: centering help please

Hey Mike,

In which part of my css do I add "margin: 0 auto;"?

Thanks

Wayne
Reply With Quote
  #4 (permalink)  
Old Aug 2nd, 2007, 09:15
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: centering help please

Quote:
Originally Posted by RZX Developer View Post
Hey Mike,

In which part of my css do I add "margin: 0 auto;"?

Thanks

Wayne
Apply this to whatever element you want centred. It also requires you to specify a width. For example, to centre the container <div id="footer">:

Code: Select all
div#footer {
width: 700px;
margin: 0 auto;
}
This will centre it horizontally inside its parent container. This could be (say) another DIV, or the viewport (if there's no higher container).

You can replace the "0" with another number if you want top and bottom margins. Or you can expand the shorthand:
Code: Select all
margin: 20px auto 10px auto;
Reply With Quote
  #5 (permalink)  
Old Aug 2nd, 2007, 09:20
Reputable Member
Join Date: Jul 2007
Location: UK, Essex
Age: 21
Posts: 172
Thanks: 0
Thanked 1 Time in 1 Post
Re: centering help please

Thanks I shall try this now

Wayne
Reply With Quote
  #6 (permalink)  
Old Aug 2nd, 2007, 09:46
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: centering help please

One more thing: it won't work in IE if you trigger quirks mode.

To avoid triggering quirks mode, use a correct Doctype.

Note that this will never work in IE5 (IE5 is always in quirks mode, as it were). There is a workaround, however.
Reply With Quote
  #7 (permalink)  
Old Aug 2nd, 2007, 09:55
Reputable Member
Join Date: Jul 2007
Location: UK, Essex
Age: 21
Posts: 172
Thanks: 0
Thanked 1 Time in 1 Post
Re: centering help please

Thanks mate
Reply With Quote
  #8 (permalink)  
Old Aug 2nd, 2007, 11:58
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: centering help please

Hmmm .... I posted that answer in the FAQ of the Webforumz Newsletter
Reply With Quote
Reply

Tags
centering help please

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
Vertical centering - please help! mpnuttall Web Page Design 6 Apr 16th, 2008 11:38
Centering a Page In CSS britishchampion Web Page Design 5 Jan 3rd, 2008 16:20
Centering website afowler Web Page Design 8 Oct 24th, 2007 18:59
Centering a DIV johnmr Web Page Design 12 Sep 13th, 2006 13:07
centering vertically benbacardi Web Page Design 17 May 27th, 2004 13:51


All times are GMT. The time now is 13:33.


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