title: Positioning button element on image using CSS
body: <p>I am working with this UI design, where I created an avatar image and also an upload button. My challenge is positioning the upload button on the image as shown below</p>
  
  <p>expectation</p>
  
  <p><a href="https://i.stack.imgur.com/z6YsT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/z6YsT.png" alt="enter image description here"></a></p>
  
  <p>but this is what I came up with</p>
  
  <p><a href="https://i.stack.imgur.com/y4KnE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y4KnE.png" alt="enter image description here"></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-js lang-js prettyprint-override"><code>document.querySelector('#btnOpenFileDialog').addEventListener('click', function() {
    document.querySelector('#fileLoader').click();
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.image-cropper {
    display: inline-block;
    border-radius: 50%;
    border: 1px solid #f2f2f2;
    overflow: hidden;
  }
  
  img {
    max-width: 100%;
    height: auto;
  }
  
  .edit-img-btn {
    position: absolute;
    color: white;
    font-size: .5rem;
    width: 22px;
    height: 22px;
    padding: 5px;
    border: 0;
    border-radius: 50%;
    background: #4169E2;
    box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.21);
  }
  
  .edit-img-btn i {
    font-size: 13px;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;span class="image-cropper" style=" width: 150px; height: 150px;"&gt;
      &lt;img src="assets/images/avatar.jpg" alt=""&gt;
    &lt;/span&gt;
  
  &lt;input type="file" id="fileLoader" style="display: none;" /&gt;
  
  &lt;button class="edit-img-btn" id="btnOpenFileDialog"&gt;&lt;i class="material-icons"&gt;edit&lt;/i&gt;&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>