这次给大家带来用css3画个同心圆,用css3画个同心圆的注意事项有哪些,下面就是实战案例,一起来看一下。
基本思路
首先你得画三个圆吧,那三个圆怎么重叠到一块呢?这个就得靠-margin来控制了。
<p id="tongxin">
<p id='t1'></p>
<p id="t2"></p>
<p id="t3"></p>
</p>
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;
}
结果
代码分析
怎么理解上述代码呢?比如t2中的margin-left:-125px。margin-top:25px; 看下面这个图
-125代表向左移动125px,25代表向下移动25px。为啥是左移动125px呢,这个就看你初中数学学的怎样了。两个圆心之间的距离嘛。大圆半径75px,中圆半径 50px。也就是说大圆的和小圆的圆心距离是125px。
垂直方向移动25px是由于垂直方向的圆心距是25px。
相信看了本文案例你已经掌握了方法,更多精彩请关注其它相关文章!
推荐阅读:
css的selector使用详解
详解css之margin的特殊使用技巧
优化单选框、复选框的样式
css优先级计算的底层规则
以上就是用css3画个同心圆的详细内容。