Jump to content


Photo

Center Div Within Div And Stll Float Them


  • Please log in to reply
2 replies to this topic

#1 pioneerx01

pioneerx01

    Advanced Member

  • Members
  • PipPipPip
  • 144 posts

Posted 06 November 2012 - 07:51 PM

I am trying to get a simple menu to have few item next to each other in the row, but still be centered with the page.

<div ID="parent">
<div ID="child">Menu Item 1</div><div ID="child">Menu Item 2</div><div ID="child">Menu Item 3</div>
</div>

How would I CSS that? I am having issues centering them on the page and keeping them next to each other at the same time.
Thanks

Edited by pioneerx01, 06 November 2012 - 07:52 PM.


#2 Volter9

Volter9

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationUS, 0xCA

Posted 06 November 2012 - 10:06 PM

To parent you're setting this properties:

#parent {

margin: 0 auto; /* Auto working only in W3C browsers, no IE, sorry <img src='http://forums.phpfreaks.com/public/style_emoticons/<#EMO_DIR#>/sad.gif' class='bbc_emoticon' alt=':(' /> */

}

To fix it in IE, you should to wrap parent div with <table align="center">

Edited by Volter9, 06 November 2012 - 10:10 PM.


#3 Drongo_III

Drongo_III

    Advanced Member

  • Members
  • PipPipPip
  • 512 posts

Posted 15 November 2012 - 02:05 PM

I am trying to get a simple menu to have few item next to each other in the row, but still be centered with the page.

<div ID="parent">
<div ID="child">Menu Item 1</div><div ID="child">Menu Item 2</div><div ID="child">Menu Item 3</div>
</div>

How would I CSS that? I am having issues centering them on the page and keeping them next to each other at the same time.
Thanks


As above. Set the parent div to be

margin: 0px auto;

And it most definitely does work in IE!
Learning something new simply uncovers how much there is left to learn...

One day when I know what I'm talking about all my noob posts will come back to haunt me. But I shall rejoice in the cleansing light of knowledge over ignorance :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com