Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Old 04-17-2009, 04:50 AM Div center alignment
Junior Talker

Posts: 2
Name: Romisha Aggarwal
Trades: 0
Hi all,

I have defined a div in which i wrote horizontal pipe links. Now, I want to center align this div. But Cudnt find anything to do that.

plz help me doing that.
Romie is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-17-2009, 10:29 AM Re: Div center alignment
Andy Pugh's Avatar
Extreme Talker

Posts: 203
Name: Andy
Location: N.Ireland
Trades: 0
I can't tell specifically what you want to do without any code, however, if you apply margin: auto; that should do what you need...

Andy
__________________

Please login or register to view this content. Registration is FREE

Last edited by Andy Pugh; 04-17-2009 at 10:30 AM.. Reason: edited because silly car kept appearing...
Andy Pugh is offline
Reply With Quote
View Public Profile
 
Old 04-17-2009, 10:42 AM Re: Div center alignment
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Code:
<div align="center">
Put that around the entire horizontal pipe links code

Code:
<div align="center">Link 1 | Link 2 | Link 3 | etc..</div>
That should do it
__________________
Made2Own

Please login or register to view this content. Registration is FREE

Last edited by Brian07002; 04-17-2009 at 10:43 AM..
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 04-19-2009, 10:49 AM Re: Div center alignment
Average Talker

Posts: 23
Name: Nikola
Trades: 0
That's working on my site, I think it'll work on yours to.
__________________

Please login or register to view this content. Registration is FREE
nikolla983 is offline
Reply With Quote
View Public Profile Visit nikolla983's homepage!
 
Old 04-20-2009, 04:52 AM Re: Div center alignment
Junior Talker

Posts: 2
Name: Romisha Aggarwal
Trades: 0
<div class="menu-navigation">
<div id="navcontainer">
<ul id="navlist">
<li id="active"><a href="#" id="current">Item one</a></li>
<li><a href="#">Item two</a></li>
<li><a href="#">Item three</a></li>
<li><a href="#">Item four</a></li>
<li><a href="#">Item five</a></li>
</ul>
</div>
</div>

.menu-navigation{
background:url(images/bg-menu.png) repeat-x;
margin:5px 0;
}
ul#navlist{
white-space: nowrap;
margin:5px 0;
line-height:3em;
}

#navlist li{
display: inline;
list-style-type: none;
margin:0;
}

#navlist a { padding: 3px 10px;}

#navlist a:link, #navlist a:visited{
color: #fff;
font-weight:bold;
font-size:12px;
text-decoration: none;
}

#navlist a:hover{
color: #000;
border:#330099 1px solid;
text-decoration: none;
}


Now, the links are showing to be left aligned. but i want it to be center aligned. when i use margin, it doesnt work without specifying width.

and when i specify fixed width, then when links will be added it will come in next line. But i want the links in one line n that too center aligned.

Hope these codes will be helpful.
[IMG]file:///C:/DOCUME%7E1/Romisha/LOCALS%7E1/Temp/moz-screenshot.jpg[/IMG]
Romie is offline
Reply With Quote
View Public Profile
 
Old 04-20-2009, 05:42 PM Re: Div center alignment
Average Talker

Posts: 18
Name: Jon
Location: Southern California
Trades: 0
.menu-navigation {
text-align:center;
background:url(images/bg-menu.png) repeat-x;
margin:5px 0;
}

Adding "text-align:center" achieved the result in FF and IE 7.
LoganKonlan is offline
Reply With Quote
View Public Profile
 
Old 04-21-2009, 12:16 AM Re: Div center alignment
Experienced Talker

Posts: 40
Name: rebo rai
Trades: 0
when you give margin-left and margin-right for a div ... it automatically gets centered !!!
mindlesswizard is offline
Reply With Quote
View Public Profile Visit mindlesswizard's homepage!
 
Old 04-21-2009, 02:42 PM Re: Div center alignment
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
No, it doesn't, not unless you SPECIFY A WIDTH first!!

Quote:
but i want it to be center aligned. when i use margin:auto, it doesnt work without specifying width.
Ok, how do you expect the browser to center something when you've given it NOTHING to go on ? Without a dimension, what would it center against ? You MUST define a width for margin: auto to work!

Add text-align: center to #navlist ul, then add padding and/or margins to space out the <li> items.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Div center alignment
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.44323 seconds with 12 queries