jquery - Div center issue -


i have main container 940 pixel

with 2 divs inside main container of width 250px each

i want these boxes centered align main container. issue second div dynamically adds. in case second div not there first 1 should center. , when second div added both should cenetered per 940 px main div.

i tried lot not solution. please help!

here simplified code

css

   div.box {     background: #eee;     height: 400px;     width: 940px; } div.left {     background: #999;     float: left;     height: 390px;     width: 250px; } div.right {     background: #666;     height: 390px;     width: 250px;     float: left; } div.clear {     clear: both; } 

html

 <div class="box">         <div class="left">tree</div>        <div class="right">view</div> ( div dynamically add)        <div class="clear" />      </div> 

thanks

try out in div.box css

 margin:0px auto; 

for demo chk out jsfiddle demo


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -