css - Making divs center if side by side or stacked -


i have 2 divs side side if window/resolution allows, , stacked 1 on top of other if doesn't.

i need them center in both cases. have managed them center 1 case or other not both.

layout:

<div class="container">    <div class="center">       <div class="left">left</div>       <div class="right">right</div>    </div> </div> 

css:

div.left {     background:blue;     height:200px;     width:250px; } div.right {     background:green;     height:300px;     width:250px; } div.center {     text-align: left;  } .container {     text-align: center; } .container div {     display: inline-block;    } 

you can see here: http://jsfiddle.net/zygnz/1784/

this way has them centered long window bigger side side elements, aligns left when 1 on top of other.

how can make centered both cases?

change .center class text-align: center:

div.center {     text-align: center; } 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -