how can i center this?

This is a discussion on "how can i center this?" within the Web Page Design section. This forum, and the thread "how can i center this? are both part of the Design Your Website category.


 Subscribe in a reader

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

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Feb 24th, 2008, 20:53
New Member
Join Date: Feb 2008
Location: bristol - uk
Age: 21
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
how can i center this?

hi i have this menu but want to center it but want it to stay relitive to the screen size can anyone help me on this?

the code i have so far is:

Code: Select all
<style type="text/css">
  
/*Credits: By Santosh Setty (http://webdesigninfo.wordpress.com) */
/*Posted to: Dynamic Drive CSS Library (http://www.dynamicdrive.com/style/) */
#wrapper {
    position: relative;
    text-align: Center;
}
.glossymenu{
 position:relative;
 padding: 0 0 0 0;
 margin: 0 -10 0 -10;
 background: url(images/menub_bg.gif) repeat-x; /*tab background image path*/
 height: 46px;
}
.glossymenu li{
 float:left;
}
.glossymenu li a{
 float: left;
 display: block;
 color:#000;
 text-decoration: none;
 font-family: sans-serif;
 font-size: 13px;
 font-weight: bold;
 padding:0 0 0 16px; /*Padding to accomodate left tab image. Do not change*/
 height: 46px;
 line-height: 46px;
 text-align: center;
 cursor: pointer; 
}
.glossymenu li a b{
 float: left;
 display: block;
 padding: 0 24px 0 8px; /*Padding of menu items*/
}
.glossymenu li.current a, .glossymenu li a:hover{
 color: #fff;
 background: url(images/menub_hover_left.gif) no-repeat; /*left tab image path*/
 background-position: left;
}
.glossymenu li.current a b, .glossymenu li a:hover b{
 color: #fff;
 background: url(images/menub_hover_right.gif) no-repeat right top; /*right tab image path*/
}
</style>

<div id="wrapper">
<ul class="glossymenu">
 <li class="current"><a href="

Last edited by Ed; Feb 25th, 2008 at 17:02. Reason: Please use [CODE] Tags
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 Feb 24th, 2008, 20:54
Jack Franklin's Avatar
Moderator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,404
Blog Entries: 8
Thanks: 18
Thanked 14 Times in 14 Posts
Re: how can i center this?

Code: Select all
#wrapper {
margin: 0 auto;
}
Centers it
__________________
Jack Franklin - Webforumz Moderator
(x)HTML | CSS | PHP | MySQL | JQuery (Javascript)
Contact: My Blog | Twitter | Delicious
Want Lessons? PM me.
If you think I've helped, please press the 'Thanks' Button.
Last Blog Entry: A Week with VBulletin (Aug 28th, 2008)
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 Feb 24th, 2008, 20:55
New Member
Join Date: Feb 2008
Location: bristol - uk
Age: 21
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Re: how can i center this?

sorry the working example can be see at http://www.poker-bingo.net/menu.html cheers.
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 Feb 24th, 2008, 20:56
New Member
Join Date: Feb 2008
Location: bristol - uk
Age: 21
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Re: how can i center this?

hmm that didnt seem to do it ??
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 Feb 24th, 2008, 23:05
Ed Ed is online now
Moderator
Join Date: Jul 2007
Location: Cork, Ireland
Posts: 730
Blog Entries: 1
Thanks: 0
Thanked 1 Time in 1 Post
Re: how can i center this?

First of all, Validate your website.

HTML: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
A lot of problems can be solved by this.

Jack, you cannot use margin: 0 auto on a div with no width.
Also, make sure you actually implement the suggested changes.

With my suggested changes, your code should look like this:

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html>

<head>
<style type="text/css">
  
/*Credits: By Santosh Setty (http://webdesigninfo.wordpress.com) */
/*Posted to: Dynamic Drive CSS Library (http://www.dynamicdrive.com/style/) */

#wrapper {
    width: 850px;
    text-align: center;
    margin: o auto;
}

.glossymenu{
    position:relative;
    padding: 0 0 0 0;
    margin: 0 -10 0 -10;
    background: url(images/menub_bg.gif) repeat-x; /*tab background image path*/
    height: 46px;
    list-style: none;

}

.glossymenu li{
    float:left;
}

.glossymenu li a{
    float: left;
    display: block;
    color:#000;
    text-decoration: none;
    font-family: sans-serif;
    font-size: 13px;
    font-weight: bold;
    padding:0 0 0 16px; /*Padding to accomodate left tab image. Do not change*/
    height: 46px;
    line-height: 46px;
    text-align: center;
    cursor: pointer;    
}

.glossymenu li a b{
    float: left;
    display: block;
    padding: 0 24px 0 8px; /*Padding of menu items*/
}

.glossymenu li.current a, .glossymenu li a:hover{
    color: #fff;
    background: url(images/menub_hover_left.gif) no-repeat; /*left tab image path*/
    background-position: left;
}

.glossymenu li.current a b, .glossymenu li a:hover b{
    color: #fff;
    background: url(images/menub_hover_right.gif) no-repeat right top; /*right tab image path*/
}

</style>

</head>

<body>

<div id="wrapper">
<ul class="glossymenu">
    <li class="current"><a href="http://www.dynamicdrive.com/"><b>Home</b></a></li>
    <li><a href="http://www.dynamicdrive.com/style/"><b>CSS</b></a></li>
    <li><a href="http://www.dynamicdrive.com/forums/"><b>Forums</b></a></li>    
    <li><a href="http://tools.dynamicdrive.com"><b>Webmaster Tools</b></a></li>    
    <li><a href="http://www.javascriptkit.com/"><b>JavaScript</b></a></li>    
    <li><a href="http://www.cssdrive.com"><b>Gallery</b></a></li>    
</ul>
</div>

</body>

</html>
I have also gotten rid of the nasty bullet points appearing in your navigation.

You may want to read up on HTML and CSS Practices before you get ahead of yourself.

Please post to let us know the outcome.

Thanks,
Ed
Last Blog Entry: Happy New Year! (Dec 31st, 2007)
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 Feb 24th, 2008, 23:57
New Member
Join Date: Feb 2008
Location: bristol - uk
Age: 21
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Re: how can i center this?

yea i know all about web standers i just put that together as a quick online example for people to help me with.

couple of issues with your modifications:

1. the bar isnt going all the way accross the page anymore

2. its still not in the center of the bar

heres what i got now:

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html>
<head>
<style type="text/css">
 
/*Credits: By Santosh Setty (http://webdesigninfo.wordpress.com) */
/*Posted to: Dynamic Drive CSS Library (http://www.dynamicdrive.com/style/) */
#wrapper {
width: 100%;
text-align: center;
margin: 0 auto;
}
.glossymenu{
position:relative;
padding: 0 0 0 0;
margin: 0 -10 0 -10;
background: url(images/menub_bg.gif) repeat-x; /*tab background image path*/
height: 46px;
list-style: none;
}
.glossymenu li{
float:left;
}
.glossymenu li a{
float: left;
display: block;
color:#000;
text-decoration: none;
font-family: sans-serif;
font-size: 13px;
font-weight: bold;
padding:0 0 0 16px; /*Padding to accomodate left tab image. Do not change*/
height: 46px;
line-height: 46px;
text-align: center;
cursor: pointer; 
}
.glossymenu li a b{
float: left;
display: block;
padding: 0 24px 0 8px; /*Padding of menu items*/
}
.glossymenu li.current a, .glossymenu li a:hover{
color: #fff;
background: url(images/menub_hover_left.gif) no-repeat; /*left tab image path*/
background-position: left;
}
.glossymenu li.current a b, .glossymenu li a:hover b{
color: #fff;
background: url(images/menub_hover_right.gif) no-repeat right top; /*right tab image path*/
}
</style>
</head>
<body>
 
<div id="wrapper">
<ul class="glossymenu">
<li class="current"><a href="

Last edited by Jack Franklin; Feb 25th, 2008 at 07:11. Reason: Added [/code] tag in your post so the text could display properly.
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 Feb 25th, 2008, 07:06
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,612
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: how can i center this?

I wish I have the Mod ability to wrap all the code inside the tag
Make your wrapper width to something smaller so they can be positioned center.
Something like {width: 50%;}
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
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

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
Div bg images..will not center? jahphill Web Page Design 5 Jun 2nd, 2008 09:03
center alexgeek Web Page Design 1 Aug 2nd, 2007 03:30
Why Cant i center Innes Web Page Design 7 Jun 20th, 2007 20:37
Center a Swf Help?? nutbolt Web Page Design 20 Apr 9th, 2007 10:21
just want to center this ragingmon Web Page Design 9 Dec 29th, 2006 18:07


All times are GMT. The time now is 02:04.


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 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