title: How to make 1 div centre align and other float right using CSS
body: <p>I want to make my div2 to centre align and div3 to be at right.</p>
  
  <p><a href="https://i.stack.imgur.com/ChRYl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ChRYl.png" alt="What is expected"></a></p>
  
  <p>I tried doing that with text align: center for main div and making float right to div3 but it is making it center align by considering main div's remaining part. I have given display: inline-flex to main div</p>
  
  <p><a href="https://i.stack.imgur.com/0gNUH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0gNUH.png" alt=" What is happening "></a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div style="height: 40px;width:120px;background-color: yellow;align-items: center;"&gt;
  
  &lt;div style="height: 20px;width:20px;background-color: red;"&gt;
    Hello
  &lt;/div&gt;
  
  &lt;div style="height: 20px;float: right;width:20px;background-color: red;"&gt;
  &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>