html - keep any div in horizontally middle -



html - keep any div in horizontally middle -

i have 2 fixed sized div , want maintain them horizontally middle if re-size screen. if remove 1 div low screen, want maintain other in middle.

here code have tried... fiddle

<div id="wrapper1"> <div id="one">1</div> <div id="two">2</div> </div>

css here...

#wrapper1 { width: 100%; height: 90px; margin: 0 auto; } #wrapper1 #one { width: 200px; height: 90px; background: white; display: inline-block; box-shadow: 0 0 5px #aaaaaa; } #wrapper1 #two { width: 100px; height: 90px; margin-left: 10px; background: white; display: inline-block; box-shadow: 0 0 5px #aaaaaa; } @media screen , (max-width: 400px) { #wrapper1 #two { display: none; } }

demo

text-align:center parent div create kid div's come in center.

css

#wrapper1 { width: 100%; height: 90px; text-align: center; /* add together create kid elements center in parent div */ }

html css

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -