【问题标题】:Flexbox unusual behaviorFlexbox 异常行为
【发布时间】:2020-02-08 00:35:20
【问题描述】:

悬停时,容器 div 右端的装订线空间为 0。它应该有一些空间,因为 justify-content 属性设置为空间均匀。如果 flex-direction 属性被移除,那么它会正常运行,但会产生锯齿状动画。是什么导致了这种行为,还有其他方法可以实现这个动画。乐于接受建议和建议。

.main{
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.container{
    width: 5rem;
    height: 5rem;
    display: flex;
    flex-direction: column;
    background: #d3d3d3;
    overflow: hidden;
    flex-wrap: wrap;
    justify-content: space-evenly;
    border: 1px solid black;
    transition: 0.5s;
}

.circle{
    width: 5rem;
    height: 5rem;
    border-radius: 50%;
    background: pink;
    border: 1px solid black;
}

.container:hover{
  width: 30rem;
<div class="main">
      <div class="container">
          <div class="circle position1"></div>
          <div class="circle position2"></div>
          <div class="circle position3"></div>
          <div class="circle position4"></div>
      </div>
  </div>

【问题讨论】:

  • 锯齿状是因为当方向设置为行时,元素在空间可用时添加到容器div,但当设置为列时,由于溢出而隐藏,动画更流畅.但是当使用方向栏时,问题仍然存在

标签: html css flexbox css-animations


【解决方案1】:

如果您将 flex 方向从列更改为行,它会起作用。我不是动画方面的专家,但它可以设置为行。

【讨论】:

  • 但动画与之前相比仍然是锯齿状的
  • 锯齿状是因为当方向设置为行时,元素在空间可用时添加到容器div,但当设置为列时,由于溢出而隐藏,动画更流畅.但是当使用方向栏时,问题仍然存在。
猜你喜欢
  • 1970-01-01
  • 2012-10-20
  • 2021-02-22
  • 1970-01-01
  • 1970-01-01
  • 2012-12-05
  • 2017-01-22
  • 2013-04-14
  • 2014-01-29
相关资源
最近更新 更多