css - Create free spaces between elements inside wrapper -


in css margins covers top , bottom margin. need reach result left end right.

--edit--

elements should align left

please see example:

.a{    width: 100px;    height: 100px;    margin: 0 12px;    border: 1px solid red;  }  .b{    width: 100px;    height: 100px;    margin: 0 12px;    border: 1px solid green;  }  .c{    width: 100px;    height: 100px;    margin: 0 12px;    border: 1px solid blue;  }  .root{   display: flex;    border: 1px solid black;  }
<div class="root">  <div class="a">  </div>  <div class="b">  </div>  <div class="c">  </div>  </div>

in case need have:

.a right margin 12px

.c left margin 12px

if there .a , .b need have:

.a right margin 12px.

if there n elements inside .root need have:

.element1 right margin 6px

.element2 left , right margin 6px

.element3 left , right margin 6px

.element4 left , right margin 6px

..... 

.elementn left margin 6px

summary margin between elements should 12px. there should no left margin first element , no right margin last element.

i show how manually, possible set in css if css level not know how many element have?

this do

.root  {    display:flex;    justify-content:space-between;   }    .a{    width: 100px;    height: 100px;    margin: 0 12px;    border: 1px solid red;  }  .b{    width: 100px;    height: 100px;    margin: 0 12px;    border: 1px solid green;  }  .c{    width: 100px;    height: 100px;    margin: 0 12px;    border: 1px solid blue;  }  .root{   display: flex;    border: 1px solid black;  }
<div class="root">  <div class="a">  </div>  <div class="b">  </div>  <div class="c">  </div>  </div>


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -