1

I have a list of cips, each with text and a remove button inside.

As can be seen in the snippet, the red button is not displayed unless the cip is hovered. This increases the width of the cip, of course. I want this increase to be smooth, not instant (see jsFiddle HERE).

body {
  font-family: Arial, sans-serif;
}

ul {
  display: flex;
  flex-wrap: wrap;
  position: relative;
  font-size: 13px;
  font-weight: 600;
}

ul li {
  display: inline-block;
  border-radius: 99px;
  background: #E3E3E3;
  padding: 0 10px;
  line-height: 28px;
  height: 28px;
  width: auto;
  transition: all 0.3s ease-in-out;
  white-space: nowrap;
  margin: 2px 4px 2px 0;
  box-sizing: border-box;
}

 ul li span {
  display: none;
  width: 18px;
  line-height: 18px;
  margin-top: 2px;
  cursor: pointer;
  border-radius: 50%;
  text-align: center;
  font-weight: 500;
  background: #c00;
  color: #fff;
}

ul li:hover .remove {
  display: inline-block;
}
<ul class="cips">
  <li>Lorem ipsum <span class="remove">&times;</span></li>
  <li> Cupiditate voluptates <span class="remove">&times;</span></li>
</ul>

The problem

Although I added transition: all 0.3s ease-in-out to the cips, the increase of the with is instantaneous, instead of smoth.

NOTA BENE: the question is about animating width NOT display.

How can I fix this and get the desired result?

Razvan Zamfir
  • 4,209
  • 6
  • 38
  • 252
  • I have **solved** the problem, **[HERE](https://jsfiddle.net/Ajax30/nqsx5e1v/1/)** is the jsFiddle. Unable to post a snippet hare because the question was closed for some reason. :( – Razvan Zamfir Oct 08 '20 at 13:29

0 Answers0