【问题标题】:Put circle top div position center [closed]将圆形顶部div位置中心[关闭]
【发布时间】:2019-01-24 17:07:06
【问题描述】:

我需要复制这个。 用css添加像这张图片这样的圆圈的最佳方法是什么?

感谢

【问题讨论】:

标签: html css


【解决方案1】:

这是一个简单的例子,如果你花时间,我认为你可以做得更好;)。

如果你想要一个完整的圆,只需为所有角而不是顶部制作 (border-radius : 50%)。

干杯

.circle{
height: 50px;
width: 100px;
border-top-left-radius:90px;
border-top-right-radius:90px;
background-color: green;
color:white;
margin: 0 auto;
text-align: center;
line-height: 50px;
}

.square{
width:500px;
height: 300px;
background-color: white;
border: 1px solid black;
margin: 0 auto;
}
  <div class="circle">1/12</div>
  <div class="square"></div>

【讨论】:

    【解决方案2】:

    我已将您的编号选项卡添加到 :before 选项卡中,以便它始终附加到您的 div。

    .square {
    position: relative;
    width: 80%;
    height: 300px;
    background-color: white;
    margin: 60px auto;
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
    }
    .square:before {
    content:'1/12';
    position: absolute; 
    top: -35px; 
    height: 65px;
    width: 65px;
    border-radius: 50%;
    z-index: -1;
    transform: translate(-50%);
    left: 50%;
    background: #4ED3CE;
    color: #fff;
    display: flex;
    justify-content: center;
    padding: 10px;
    }
      
    <div class="square">
        
    </div>

    【讨论】:

      【解决方案3】:

      你可以用下面的代码实现半圆,然后你可以自己定制

       
      
      div {
        background: #9e978e;
        display: inline-block;
        margin: 0 1em 1em 0;
      }
      
      .top,
      .bottom {
        height: 45px;
        width: 90px;
      }
      
      .right,
      .left {
        height: 90px;
        width: 45px;
      }
      
      .top {
        border-top-left-radius: 90px;
        border-top-right-radius: 90px;
      }
      
      .right {
        border-bottom-right-radius: 90px;
        border-top-right-radius: 90px;
      }
      
      .bottom {
        border-bottom-left-radius: 90px;
        border-bottom-right-radius: 90px;
      }
      
      .left {
        border-bottom-left-radius: 90px;
        border-top-left-radius: 90px;
      }
      
      .rotate {
        animation: 1s linear infinite rotate;
        position: relative;
        top: $size * -1;
        transform-origin: 50% 100%;
      }
      
      @keyframes rotate {
        from {
          transform: rotate(0deg)
        }
        to {
          transform: rotate(360deg)
        }
      }
      <div class="top"></div>
      <div class="right"></div>
      <div class="bottom"></div>
      <div class="left"></div>
      <div class="rotate top"></div>

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-05-16
        • 1970-01-01
        • 2014-06-16
        • 1970-01-01
        • 2014-11-28
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多