How to make one circle inside of another using CSS

后端 未结 13 2337
-上瘾入骨i
-上瘾入骨i 2020-12-30 03:54

I am trying to make one circle inside of another circle using css, but I am having an issue making it completely centered. I am close, but still not there. Any ideas?

<
13条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-30 04:42

    Ta da!

    Explained in the CSS comments:

     #outer-circle {
       background: #385a94;
       border-radius: 50%;
       height: 500px;
       width: 500px;
       position: relative;
       /* 
        Child elements with absolute positioning will be 
        positioned relative to this div 
       */
     }
     #inner-circle {
       position: absolute;
       background: #a9aaab;
       border-radius: 50%;
       height: 300px;
       width: 300px;
       /*
        Put top edge and left edge in the center
       */
       top: 50%;
       left: 50%;
       margin: -150px 0px 0px -150px;
       /* 
        Offset the position correctly with
        minus half of the width and minus half of the height 
       */
     }

提交回复
热议问题