Как сделать гибкий переход плавным.В моем примере, когда я нажимаю .center, он резко скачет.Это еще более заметно, когда пользователь нажимает на документ, переходы .right fadeOut и .center заполняют все пространство.Могу ли я сделать это движение .center более плавным?(аналогично fadeIn и fadeOut of .right)
Я не знаю, можно ли это сделать с помощью flex-перехода?Я пробовал и без разницы: переход: все 4s;
$(".center").click(function(e) {
e.stopPropagation();
$(".right").fadeIn(400);
});
// click outside
$(document).click(function() {
$(".right").fadeOut(400);
});
#wrap {
position: relative;
margin: 20px auto;
width: 80%;
background-color: red;
}
.row {
position: relative;
height: 30px;
margin-bottom: 10px;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
background-color: lightgray;
}
.center {
min-height: 30px; line-height: 30px;
text-align: center;
background-color: blue;
flex-grow: 1;
}
.right {
width: 50px; height: 30px; line-height: 30px;
display: inline-block;
text-align: center;
margin-left: 10px;
background-color: grey;
display:none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>
<div id="wrap">
<div class="row">
<div class="center">center</div>
<div class="right">right</div>
</div>
<div class="row">
<div class="center">center</div>
<div class="right">right</div>
</div>
</div>