Web Hosting Talk







View Full Version : Having Trouble Centering a DIV


Liguidsoul
03-08-2008, 10:23 PM
I've been trying for the past 30 minutes but I'm having trouble centring the "DIV" that contains the drop-down menus.

http://72.34.44.150/~davidcom/naama/

Your input would be greatly appreciated. I'll even PayPal $5 to the first person who can figure out what I'm doing wrong.

Chris Patti
03-08-2008, 10:27 PM
You could try the basic align tag. Like wrapping the container div like this <div align="center">menu</div>

Its basic and newby but it may work.

Metallian
03-09-2008, 01:10 AM
try this


in html

<div id="center"> blah </div>



in css

#center {
margin: 0 auto;
}

WebDesignGold
03-09-2008, 06:31 AM
You have to enclose everything in a main container then give it margin: 0 auto;
The menu container "#menuh-container" is absolute positioned. Remove that and just use floats. When the main container you're going to add is centered, everything else which isn't absolute positioned will be centered too.

eviltechie
03-20-2008, 04:10 PM
Here's how...

HTML:

<div id="menuwrapper">
<div id="menuh-container">
<div id="menuh">
...MENU STUFF HERE...
</div>
</div>
</div>


CSS:

<style type="text/css">
#menuh-container {
width: 840px;
padding: 90px 0px 0px 0px;
text-align:left;
}
#menuwrapper {
width:100%;
text-align:center;
}
</style>



That should do it.

jerett
03-20-2008, 04:21 PM
You could just setup a nav wrap like so:



<div id="nav-wrap">
Menu Information Here
</div>



In your style sheet (CSS) just put this:



#nav-wrap {
margin: auto;
}



Of course you can do what ever else you want with it but the simplest way is to add the margin: auto; .

trevhub
03-20-2008, 05:32 PM
Like Jerret said, set your margin for "menuh" to auto and just make sure you have text-align set to center for menuhcontainer, both done in your css. The div align="center" you have there now won't do you anything.