CSS:五环

描述:用5个div写成imgs/奥运五环

思路:

  • (1)将五个div的边框设置为50%,成为圆形;
  • 再使用绝对定位将元素设置到不同的位置,(注意:设置定位的元素的left/top/right/bottom默认值是auto,不是0)
  • 再将每个元素下使用伪类添加一个相同属性的圆形
  • 再利用z-index属性对元素中间夹实现五环(注意:定位的元素z-index才有效)
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>circle</title>
    <style>
        *{
            margin: 0px;
            padding: 0px;
        }
        .circle,.circle::after{
            width: 200px;
            height:200px;
            border: 10px solid #0000ff;
            -webkit-border-radius: 50%;
            -moz-border-radius: 50%;
            border-radius: 50%;
            position: absolute; 
        }
        .circle::after{
            content: "";  
            top:-10px;
            left:-10px; 
        }

        .circle1{
           top:0px;
           left:0px;
            
        }
        .circle1::after{
            z-index: 1;
            border-bottom-color: transparent;
            
        }
        .circle2{
            border-color: #000000;
            top:0;
            left:230px;
        }
        .circle2::after{
            border-color: #000000;  
            z-index: 1;
            border-left-color: transparent;
             
        }
        .circle3{
            border-color: #ff0000;
            top:0;
            left:460px;
        }
        .circle3::after{
            border-color: #ff0000;
            z-index: 1;
            border-left-color: transparent;
         
        }
        .circle4{
            border-color: #ffff00;
            left:110px;
            top: 110px;
        }
        .circle4::after{
            border-color: #ffff00;
          
         
        }
        .circle5{
            border-color: #00ff00;
            top: 110px;
            left:340px;
        }
        .circle5::after{
            border-color: #00ff00;
            z-index: 2;
            border-top-color: transparent;
            border-right-color: transparent;
           
          

        }

    </style>
</head>
<body>
<div class="circle circle1"></div>
<div class="circle circle2"></div>
<div class="circle circle3"></div>
<div class="circle circle4"></div>
<div class="circle circle5"></div>

</body>
</html>

转载于:https://my.oschina.net/u/4045971/blog/3025758

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值