Jasbindar Singh
Jasbindar Singh

Reputation: 79

Flexbox unusual behavior

When hovered, the gutter space at the right end of the container div is 0. It should have some space as the justify-content property is set to space-evenly. If the flex-direction property is removed then it acts normal but it gives a jagged animation. What is causing this behavior and is there any other way to achieve this animation. Open to advise and suggestions.

.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>

Upvotes: 0

Views: 82

Answers (1)

Leyser S.
Leyser S.

Reputation: 23

It works if you change flex direction from column to row. I'm no expert in animations, but it works having it set to row.

Upvotes: 1

Related Questions