DIV&CSS多种方式实现同心圆

本文介绍了通过div嵌套、border属性和boxshadow效果,以及径向渐变等多种方法,详细阐述如何在网页中实现美观的同心圆效果,是提升CSS布局技能的好帮手。

div嵌套

利用border和boxshadow

径向渐变 

<!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>
</head>
<body>
  <div class="container">
    <!--div 嵌套 -->
    <div class="circle-outer content">
      <div class="circle">
        <div class="circle-inner"></div>
      </div>
    </div>
  </div>
  <div class="container">
    <!--利用border和boxshadow-->
    <div class="circle-shadow content"></div>
  </div>
  <div class="container">
    <div class="circle-rrg content"></div>
  </div>
  <style>
    .container {
      float: left;
      width: 45px;
      height: 45px;
    }
    .content {
      margin: auto;
    }
    /*方法1 利用div嵌套*/
    .circle-outer {
      position: relative;
      height: 30px;
      width: 30px;
      background-color: rgba(2, 238, 255, 0.2);
      border-radius: 50%;
    }
    .circle {
      position: absolute;
      left: 5px;
      top: 5px;
      height: 20px;
      width: 20px;
      background-color: rgba(2, 238, 255, 0.4);
      border-radius: 50%;
    }
    .circle-inner {
      position: absolute;
      left: 5px;
      top: 5px;
      height: 10px;
      width: 10px;
      background-color: #02eeff;
      border-radius: 50%;
    }
    /*方法2 利用border和boxshadow*/
    .circle-shadow {
      width: 10px;
      height: 10px;
      border-radius: 50%;
      border: 5px solid rgba(2, 238, 255, 0.4);
      background-color: rgba(2, 238, 255, 1);
      box-shadow: 0 0 0 5px rgba(2, 238, 255, 0.2);
      background-clip: padding-box;
    }
    /*方法3 径向渐变*/
    .circle-rrg {
      width: 30px;
      height: 30px;
      border-radius: 50%;
      background: repeating-radial-gradient(rgba(2, 238, 255, 1) 0px 5px,rgba(2, 238, 255, 0.4) 5px 10px, rgba(2, 238, 255, 0.2) 10px 15px);
    }
  </style>
</body>
</html>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值