html - Div alignments in CSS -


i have alignment in image based on number of sub divs, using css/html , bootstrap.

  1. full width can hold upto 3 divs (i.e. .container)
  2. if 2 divs shown should center aligned.

as of now, divs align left or right.

what easy way achieve css/html? not sure keywords should search on google - there lot of articles talking centering divs.

enter image description here

set div inline-block , wrapper text-align: center:

.wrapper { text-align: center; }  .wrapper div {    width: 100px;    height: 100px;    background: red;    display: inline-block;    margin: 20px;  }
<div class ="wrapper">    <div></div>    <div></div>    <div></div>  </div>  <div class="wrapper">    <div></div>    <div></div>  </div>


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

python - RuntimeWarning: PyOS_InputHook is not available for interactive use of PyGTK -