基本思路
首先你得畫三個圓吧,那三個圓怎么重疊到一塊呢?這個就得靠-margin來控制了。
<div id="tongxin">
<div id='t1'></div>
<div id="t2"></div>
<div id="t3"></div>
</div>
css
#t1 {
float:left;
width:150px;
height:150px;
background: pink;
border-radius:75px ;
}
#t2 {
float:left;
width:100px;
height:100px;
margin-left:-125px;/*move to left 125px*/
margin-top:25px;/* move to bottom 25px*/
background: green;
border-radius: 50px;
}
#t3 {
float:left;
width:50px;
height:50px;
margin-left:-100px;/*move left 100px*/
margin-top:50px;
background: yellow;
border-radius: 25px;
}
結果
image.png
怎么理解上述代碼呢?比如t2中的margin-left:-125px。margin-top:25px; 看下面這個圖
-125代表向左移動125px,25代表向下移動25px。為啥是左移動125px呢,這個就看你初中數學學的怎樣了。兩個圓心之間的距離嘛。大圓半徑75px,中圓半徑 50px。也就是說大圓的和小圓的圓心距離是125px。
垂直方向移動25px是由于垂直方向的圓心距是25px。
image.png
總結
理解margin數值代表的移動方向這個事情就搞定了!