css 在一行中对齐多个循环项目时遇到问题

roejwanj  于 2023-01-06  发布在  其他
关注(0)|答案(2)|浏览(135)

我创建了一个圆形,在其中显示一些百分比。我想把多个项目放在一行中。
我试过使用div和make display flex,但没有任何东西能正常工作。以下是我到目前为止尝试的:

.meal-circular-progress{
  position: relative;
  height: 100px;
  width: 100px;
  border-radius: 50%;
  background: conic-gradient(#7d2ae8 0deg, #ededed 0deg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin:auto;
 //transition: background 2s;
 //transition-timing-function: ease; 
 //border: 1px solid red;
}
.meal-circular-progress::before{
  content: "";
  position: absolute;
  height: 80px;
  width: 80px;
  border-radius: 50%;
  background-color: #fff;
//border: 1px solid red;
}


.progress-value{
   position: relative;
   font-size: 40px;
   font-weight: 600;
   color: #7d2ae8;
}
<div class="col-sm-6  center">
      <div class="meal-circular-progress" ng-style="c.circular">
        <span class="progress-value">10%</span>
      </div>
      <div class="meal-circular-progress" ng-style="c.circular">
        <span class="progress-value">10%</span>
      </div>
      <div class="meal-circular-progress" ng-style="c.circular">
        <span class="progress-value">10%</span>
      </div>
</div>
nmpmafwu

nmpmafwu1#

你需要使你的父元素为flexbox,在本例中你的父元素为center
将该元素设置为flexbox,并使用align-items属性执行此操作:

.center {
      display: flex;
      align-items: center;
      justify-content: center;
  }

 .meal-circular-progress {
      position: relative;
      height: 100px;
      width: 100px;
      border-radius: 50%;
      background: conic-gradient(#7d2ae8 0deg, #ededed 0deg);
      display: flex;
      align-items: center;
      justify-content: center;
      margin: auto;
  }

 .meal-circular-progress::before {
      content: "";
      position: absolute;
      height: 80px;
      width: 80px;
      border-radius: 50%;
      background-color: #fff;
  }

  .progress-value {
       position: relative;
       font-size: 40px;
       font-weight: 600;
       color: #7d2ae8;
   }
<div class="col-sm-6  center">
      <div class="meal-circular-progress" ng-style="c.circular">
        <span class="progress-value">5%</span>
      </div>
      <div class="meal-circular-progress" ng-style="c.circular">
        <span class="progress-value">10%</span>
      </div>
      <div class="meal-circular-progress" ng-style="c.circular">
        <span class="progress-value">20%</span>
      </div>
</div>
y3bcpkx1

y3bcpkx12#

弯曲容器
https://codepen.io/mplungjan/pen/xxJEPwx

#container {
  display: flex;
  flex-direction: row;
  min-width: max-content;
  max-width: max-content; /* optional */
  border: 1px solid black;
}

相关问题