html - How to Center and Right-align on a row with CSS Flex only -


tried many variations this, not work. here last attempt:

.parent {   display: flex;   //justify-content: center;   width: 600px;   background-color: yellow } .c {   //flex: 1 1 0;   //text-align: end;   margin-left: auto;   margin-right: auto;   background-color: cyan; }   .e {   //flex: 1 1 0;   // text-align: end;   background-color: grey; }   .bs {   background-color: green;   color: white;   width: 70px; } 

with html:

<div class="parent">   <div class="c">     <button class="bs">ok</button>     <button class="bs">cancel</button>   </div>   <div class="e">     <button class="bs">help</button>   </div> </div> 

i know how solve placing 'visibility: hidden' button on left-hand side , use justify-content space-between, want learn/know how using css only.

would grateful advice.

there more 1 way that.

here css (no markup/hidden element) using pseudo , make , each button wrapper take 1/3 each of total width, giving them flex-basis: 100% , default flex-shrink: 1 shrink them equally.

.parent {    display: flex;    width: 600px;    background-color: yellow  }  .parent::before, .c, .e {    content: '';    flex-basis: 100%;  }  .c {    background-color: cyan;    text-align: center;  }    .e {    background-color: grey;    text-align: right;  }    .bs {    background-color: green;    color: white;    width: 70px;  }
<div class="parent">    <div class="c">      <button class="bs">ok</button>      <button class="bs">cancel</button>    </div>    <div class="e">      <button class="bs">help</button>    </div>  </div>


the above solution based on answer gave here:

and here 3 more ways, first sample solve without markup using absolute positioning


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -