div成圆形分布

1.  css3

  

    ul{
                width: 200px;
                height: 200px;
                background-color:black;
                border-radius: 50%;
                position: relative;
      margin: 100px;
            }
            li{
                width: 20px;
                height: 20px;
                position: absolute;
                background-color:red;
                border-radius: 50%;
                line-height: 40px;
                text-align: center;
                left: 50%;
                margin-left: -10px;
                margin-top: -10px;
      font-size: 12px;
            }
            li:nth-of-type(2){
                transform: rotate(36deg);
                transform-origin:10px 110px;
            }
            li:nth-of-type(3){
                transform: rotate(72deg);
                transform-origin:10px 110px;
            }
            li:nth-of-type(4){
                transform: rotate(108deg);
                transform-origin:10px 110px;
            }
            li:nth-of-type(5){
                transform: rotate(144deg);
                transform-origin:10px 110px;
            }
            li:nth-of-type(6){
                transform: rotate(180deg);
                transform-origin:10px 110px;
            }
            li:nth-of-type(7){
                transform: rotate(216deg);
                transform-origin:10px 110px;
            }
            li:nth-of-type(8){
                transform: rotate(252deg);
                transform-origin:10px 110px;
            }
            li:nth-of-type(9){
                transform: rotate(288deg);
                transform-origin:10px 110px;
            }
            li:nth-of-type(10){
                transform: rotate(324deg);
                transform-origin:10px 110px;
            }
    <ul>
      <li>1</li>
      <li>2</li>
      <li>3</li>
      <li>4</li>
      <li>5</li>
      <li>6</li>
      <li>7</li>
      <li>8</li>
      <li>9</li>
      <li>10</li>
    </ul>
 
 
 
 
2. js计算+position定位实现
 
  *{ margin: 0; padding: 0;}
  .modepayment-content{
    width: 300px;
    height: 300px;
    background: red;
    border-radius: 100%;
    position: relative;
    left: 300px;
    top: 300px;
  }
  .modepayment-content div{
    position: absolute;
  }
 
 
  <div class="modepayment-content">
    <div class="modepayment-wx">微信</div>
    <div class="modepayment-zfb">支付宝</div>
    <div class="modepayment-xj">现金</div>
    <div class="modepayment-hyk">会员卡</div>
    <div class="modepayment-yl">银联</div>
    <div class="modepayment-hh">混合</div>
    <div class="modepayment-gd">更多</div>
    <div class="modepayment-hh">混合</div>
    <div class="modepayment-gd">更多</div>
    <div class="modepayment-hh">混合</div>
    <div class="modepayment-gd">更多</div>
  </div>
 
  
 
  $(function(){
    var radius =180;
    var avd = 360/$(".modepayment-content div").length;
    var ahd = avd*Math.PI/180;
    $(".modepayment-content").css({"left":800,"top":200});
    $(".modepayment-content div").each(function(index, element){
      $(this).css({"bottom": Math.sin((ahd*index))*radius+140,"right":Math.cos((ahd*index))*radius+135});
    });
  })
 
 
  

转载于:https://www.cnblogs.com/Mr-Rshare/p/10095929.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值