Connecting Tech Pros Worldwide Forums | Help | Site Map

aligh div in center position and it was contain two div both are flot in left

Newbie
 
Join Date: Oct 2009
Posts: 1
#1: Oct 4 '09
hai i am satheesh i am a student,

actually i was make a one web page, here it contain one parent div, and the parent div contain three div,

how can i align center for the children div

code are follow:
Expand|Select|Wrap|Line Numbers
  1. <div style="width:100%; height:100%; background:#99FFCC; margin:auto;" align="center" >
  2.     <div style="background-color:#999999;">
  3.       <div style="background-color:#FF0000; width:400px; height:100px; float:left;">children div 1</div>
  4.       <div style="background-color:#FF0000; width:400px; height:100px;float:left;">children div 2</div>
  5.       <div style="background-color:#FF0000; width:400px; height:100px;float:left;">children div 3</div>
  6.     </div>
  7. </div>
  8.  
but i expect for the child div in flot:left, because all div in single row


please any body help me sir !!!!!!!!!!!!!!!!!

TheServant's Avatar
Expert
 
Join Date: Feb 2008
Location: Australia
Posts: 914
#2: Oct 15 '09

re: aligh div in center position and it was contain two div both are flot in left


There is only one legitimate way to center divs on the web and that's using:
Expand|Select|Wrap|Line Numbers
  1. margin: 0 auto;
. Now the other issue is that requires your parent dive to be given a width. So in your second level div, with the background-color: #999999, add in:
Expand|Select|Wrap|Line Numbers
  1. display: block;
  2. margin: 0 auto;
  3. width: 800px;
And then go from there. Welcome to Bytes.
Reply