用css写一个有趣的奥运五环~。

用css实现奥运五环样式,并且于页面居中显示,不随页面滚动条而移动,一直处于居中位置。

 

html代码部分就一个div里边包含5个div。代码如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

    <!-- <link rel="stylesheet" type="text/css" href="./test2.css"> -->
<style>
         
 div.main{
    position: fixed;
    left: 50%;
    top: 50%;
    margin-left: -190px;
    margin-top: -95px;

}

div.cir1{
    width: 100px;
    height: 100px;
    border:10px solid #00f;
    border-radius: 50%;
    z-index: 1;
    position: relative;
}

div.cir2{
    width: 100px;
    height: 100px;
    border: 10px solid #ff0;
    border-radius: 50%;
    z-index: 2;
    position: absolute;
    left: 60px;
    top: 50px;
}

div.cir3{
    width: 100px;
    height: 100px;
    border: 10px solid #000;
    border-radius: 50%;
    z-index: 1;
    position: absolute;
    left: 130px;
    top: 0px;
}

div.cir4{
    width: 100px;
    height: 100px;
    border: 10px solid #0f4;
    border-radius: 50%;
    z-index: 1;
    position: absolute;
    left:200px;
    top:50px;
}

div.cir5{
    width: 100px;
    height: 100px;
    border: 10px solid #f00;
    border-radius: 50%;
    z-index: 2;
    position: absolute;
    left: 260px;
    top: 0px;
} 

    </style>    

</head>
<body>
      
   <div class="main">  
        <div class="cir1"></div>
        <div class="cir2"></div>
        <div class="cir3"></div>
        <div class="cir4"></div>
        <div class="cir5"></div>
    </div>  
   

</body>
</html>

 效果图:

 

 

 

 

 

 

 

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值