Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 2013 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     HTML/XHTML/DHTML/CSS :

Centering Help

Thread title: Centering Help
Closed Thread    
    Thread tools Search this thread Display Modes  
10-10-2006, 11:58 PM
#1
KewL is offline KewL
Status: OG
Join date: Apr 2006
Location: California
Expertise: Design, Music, Xhtml, Css
Software: Photoshop, Coda, FL Studio
 
Posts: 2,007
iTrader: 11 / 100%
 

KewL is an unknown quantity at this point

  Old  Centering Help

Hey everyone, we are trying to get the buttons on the navibar centered on all resolutions. As of right now you can only see it centered on 1024,768 or less.

http://www.skinwp.com/dev/index.php?...al_id=&cal_id=


Code:
	<div id="navigation" style="padding-left: 25%;">
<p>
<a href="{ipb.script_url}"><div class="nav_home"></div></a>
<a href="{ipb.script_url}act=Search&amp;f={ipb.input['f']}"><div class="nav_search"></div></a>
<a href="{ipb.script_url}act=Members"><div class="nav_members"></div></a>
<a href="{ipb.script_url}act=calendar"><div class="nav_calendar"></div></a>
<a href="{ipb.script_url}act=Help"><div class="nav_help"></div></a>
</p>
	</div>

CSS:
#navigation{
	background: url(<#IMG_DIR#>/navigation_tile.gif);
	height: 39px;
	padding: 0;
	margin: 0px auto 0px auto;
}

#navigation p{
	display: inline;
	margin: 0px auto 0px auto;
	padding: 0;
	text-align: center;
}

.nav_home{
	background: url(<#IMG_DIR#>/navigation_home.gif);
	height: 39px;
	width: 89px;
	padding: 0;
	margin: 0;
	float: left;
}

.nav_home:hover{
	background: url(<#IMG_DIR#>/navigation_home2.gif);
	height: 39px;
	width: 89px;
}

.nav_search{
	background: url(<#IMG_DIR#>/navigation_search.gif);
	height: 39px;
	width: 89px;
	padding: 0;
	margin: 0;
	float: left;
}

.nav_search:hover{
	background: url(<#IMG_DIR#>/navigation_search2.gif);
	height: 39px;
	width: 89px;
}

.nav_members{
	background: url(<#IMG_DIR#>/navigation_members.gif);
	height: 39px;
	width: 89px;
	padding: 0;
	margin: 0;
	float: left;
}

.nav_members:hover{
	background: url(<#IMG_DIR#>/navigation_members2.gif);
	height: 39px;
	width: 89px;
}

.nav_calendar{
	background: url(<#IMG_DIR#>/navigation_calendar.gif);
	height: 39px;
	width: 89px;
	padding: 0;
	margin: 0;
	float: left;
}

.nav_calendar:hover{
	background: url(<#IMG_DIR#>/navigation_calendar2.gif);
	height: 39px;
	width: 89px;;
}

.nav_help{
	background: url(<#IMG_DIR#>/navigation_help.gif);
	height: 39px;
	width: 89px;
	padding: 0;
	margin: 0;
	float: left;
}

.nav_help:hover{
	background: url(<#IMG_DIR#>/navigation_help2.gif);
	height: 39px;
	width: 89px;
}

10-11-2006, 05:11 AM
#2
Andrew R is offline Andrew R
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
 
Posts: 5,200
iTrader: 17 / 95%
 

Andrew R is on a distinguished road

  Old

Set a width to your main navigation div (which only includes the buttons) and add a set width. Then your margin properties will automatically center it.

10-11-2006, 05:19 AM
#3
Dan Schulz is offline Dan Schulz
Dan Schulz's Avatar
Status: I'm new around here
Join date: Oct 2006
Location: Aurora, Illinois
Expertise:
Software:
 
Posts: 15
iTrader: 0 / 0%
 

Dan Schulz is on a distinguished road

Send a message via ICQ to Dan Schulz Send a message via AIM to Dan Schulz

  Old

Try fixing the validation errors in your code first, then referesh in your browsers.
http://validator.w3.org/check?uri=ht...al_id=&cal_id=

Also check your stylesheet for any validation errors at http://jigsaw.w3.org/css-validator/ as well. I tried running your stylesheet through the validator, but it was just too long. Try moving it to an external file, link to it, and then run the link through the validator. If there are any errors or warnings, fix them, re-valdiate, and then check in your browsers.

10-11-2006, 06:28 PM
#4
Steveh is offline Steveh
Status: I'm new around here
Join date: Sep 2006
Location:
Expertise:
Software:
 
Posts: 8
iTrader: 0 / 0%
 

Steveh is on a distinguished road

  Old

Originally Posted by AndrewR
Set a width to your main navigation div (which only includes the buttons) and add a set width. Then your margin properties will automatically center it.
I tried setting the width as 100% for the div aswell as the p, but it's not centering. Keep in mind, the buttons are floated left.

10-11-2006, 06:31 PM
#5
EEight is offline EEight
EEight's Avatar
Status: Member
Join date: Sep 2006
Location: New York City
Expertise:
Software:
 
Posts: 230
iTrader: 0 / 0%
 

EEight is on a distinguished road

Send a message via AIM to EEight

  Old

Try something like this for whatever is containing the buttons:

{
width: XXXpx;
position: relative;
left: 50%;
margin: 0 0 0 -ZZZpx;
}

XXX is the width of the container. ZZZ is half of XXX (don't forget the minus sign). What this does is position the left edge of the element exactly in the center of the page, and then nudges it to the left exactly half its own width.

10-11-2006, 06:34 PM
#6
Steveh is offline Steveh
Status: I'm new around here
Join date: Sep 2006
Location:
Expertise:
Software:
 
Posts: 8
iTrader: 0 / 0%
 

Steveh is on a distinguished road

  Old

But you see, the skin is designed to work with percents. There is no exact width of my navigation bar.

10-11-2006, 06:46 PM
#7
derek lapp is offline derek lapp
Status: design rockstar
Join date: Jan 2005
Location: guelph, ontario
Expertise:
Software:
 
Posts: 2,246
iTrader: 0 / 0%
 

derek lapp is on a distinguished road

  Old

use auto:

element {
width: XX%;
margin: 0 auto;
}

10-11-2006, 07:08 PM
#8
thatjamie is offline thatjamie
thatjamie's Avatar
Status: Ruby on Rails Developer
Join date: Oct 2004
Location: England, UK
Expertise: Ruby, Rails, jQuery
Software: Chocolat, Sublime Text 3
 
Posts: 2,343
iTrader: 14 / 94%
 

thatjamie is on a distinguished road

Send a message via Skype™ to thatjamie

  Old

You got any floats in there? If so then make sure to use clear: both;

10-11-2006, 07:28 PM
#9
Steveh is offline Steveh
Status: I'm new around here
Join date: Sep 2006
Location:
Expertise:
Software:
 
Posts: 8
iTrader: 0 / 0%
 

Steveh is on a distinguished road

  Old

I really appreciate the help guys, but I re-did the navigation using a list. It works fine and centers.
Thanks everyone!

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed