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">×</span></li>
<li> Cupiditate voluptates <span class="remove">×</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?