0

I want the blue tag to be right in the middle of the gray tag.

enter image description here

Using the position of this tag is not in the middle

    .container {
      width: 100vw;
      height: 100vh;
     }
    .parent {
      width: 200px;
      height: 200px;
      background-color: gray;
      border-radius: 30px;
      margin: 0 auto;
      position: relative;
  
     }
     .child {
       width: 20px;
       height: 20px;
       background-color: lightblue;
       position: absolute;
       top: 50%;
       left: 50%;
      }
<div class="container">
     <div class="parent">
       <div class="child"></div>
     </div>
    </div>
Libra
  • 2,544
  • 1
  • 8
  • 24
farhad
  • 26
  • 4
  • Your code seems to work as expected, I edited your question to run as a snippet and it behaves as expected. – Libra Jan 21 '21 at 17:30
  • Does this answer your question? [Center an element with "absolute" position and undefined width in CSS?](https://stackoverflow.com/questions/1776915/center-an-element-with-absolute-position-and-undefined-width-in-css) – Libra Jan 21 '21 at 17:31

0 Answers0