CSS3制作奥运五环(带白色边框)--精简篇

网上已经有有很多用CSS3写的奥运五环效果,但觉得写的有点乱,代码不够精简。所以今天整理了一下,写的可能不是很好,大神就秒过吧。

整体思路:1.用 li标签画出圆圈效果

     2.用 li:before画出圆圈外层圆边框

     3.用 li:after画出圆圈内层圆边框

Chrome运行效果截图

废话不多说了,上代码

<!DOCTYPE html>   
<html>   
 <head>   
     <meta charset="UTF-8" />   
     <title>The Olympic Flag</title>    
     <style type="text/css" media="screen">   
     body{
        background:tan;
     }

     .flag li{  
        position:absolute;  
         border-radius:6em;  
         border: solid 1em;  
         width: 10em;  
         height: 10em;  
         list-style-type:none;  
     }    
       
     .flag .blue   { z-index: 10; left: 0; top: 0; border-color: blue; }  
     .flag .yellow { z-index: 20; left: 6.8em;  top: 5.7em; border-color: yellow; }  
     .flag .black  { z-index: 21; left: 13.6em; top: 0; border-color: black; }  
     .flag .green  { z-index: 20; left: 20.4em; top: 5.7em; border-color: green; }  
     .flag .red    { z-index: 10; left: 27.2em; top: 0px; border-color: red; }     
       
     li:after{
        position:absolute;
        content:"";
        display:block;
        top:0em;
        left:0em;
        right:0em;
        bottom:0em;
        border:0.3em solid #eee;
        border-radius:6em;
     }      
     li:before{
        position:absolute;
        content:"";
        display:block;
        border:0.3em solid #eee;
        border-radius:12em;
        top:-1em;
        right:-1em;
        bottom:-1em;
        left:-1em;
     }
     /* 蓝色压住黄色 */    
     .flag .blue.alt { z-index: 24; }  
     .flag .blue.alt,.blue.alt:after,.blue.alt:before  
     {
         border-top-color: transparent;  
         border-left-color: transparent;  
         border-bottom-color: transparent;  
     }  
     /* 黄色压住黑色 */  
     .flag .yellow.alt { z-index: 23; }  
     .flag .yellow.alt,.yellow.alt:after,.yellow.alt:before
      {  
         border-right-color: transparent;  
         border-left-color: transparent;  
         border-bottom-color: transparent;  
     }      
     /* 绿色压住黑色  */  
     .flag .green.alt { z-index: 23; }  
     .flag .green.alt,.green.alt:after,.green.alt:before
     {  
         border-top-color: transparent;  
         border-right-color: transparent;  
         border-bottom-color: transparent;  
     }  
     /* 红色压住绿色  */  
     .flag .red.alt { z-index: 23; }  
     .flag .red.alt,.red.alt:after,.red.alt:before
    {  
         border-top-color: transparent;  
         border-right-color: transparent;  
         border-left-color: transparent;  
     }
     </style>     
 </head>   
 <body>   
    <ul class="flag">   
         <li class="blue"></li>   
         <li class="blue alt"></li>   
         <li class="yellow test"></li>   
         <li class="yellow alt"></li>   
         <li class="black"></li>   
         <li class="green"></li>   
         <li class="green alt"></li>   
         <li class="red"></li>   
         <li class="red alt"></li>   
     </ul>     
 </body>   
</html> 

转载于:https://www.cnblogs.com/wuLiuyang/p/4186655.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值