What am i trying to do
My goal is to list the list so that when you click on an element, it smoothly rises to the top of the list, becoming a heading (see example). Actually, under it the user interface of the menu will be displayed. I can move the height of all the elements except one click to smoothly animate it to the top of the list. It works! But the text, when the container gets too small, the text, of course, just disappears. My intention is for the text to be pinched too.
What i tried
So, of course, I have to use conversion. However, the transformation visually visualizes the container, but does not physically change the space in which it lives, so the item with the list pressed does not rise up.
Finally, when I try to convert the container at the same time and change its height to zero, the result is not as expected. The change in height is taken into account as a result of the transformation, and the text still just disappears.
In addition, gaps arise between the elements, since the transformation actually takes into account the change in height, which makes them visually faster than their size can be reduced!
My question
How can I simultaneously transform the container and physically reduce its height to zero in a smooth, fluent , without text disappearing at any point until it becomes pinched . zero height (and without gaps between average transitions of elements)?
Example:
@import url(https://fonts.googleapis.com/css?family=Lobster); html, body, div { padding: 0; margin: 0; box-sizing: border-box; } .wrapper { margin: 10px; width: 2in; height: 3in; display: -ms-flexbox; display: -webkit-flex; display: flex; flex-direction: column; font-family: 'Lobster', cursive; border-style: solid; border-width: 1px; border-color: lightgray; } .wrapper > .container { width: 100%; height: 0.6in; display: -ms-flexbox; display: -webkit-flex; display: flex; cursor: pointer; transition: transform 0.3s, background-color 0.3s, color 0.3s; } .wrapper .container:nth-child(even) { background-color: lightgray; } .wrapper .container:hover { background-color: gray; color: white; } .wrapper > .container > .name { display: -ms-flexbox; display: -webkit-flex; display: flex; -ms-flex-align: center; -webkit-align-items: center; -webkit-box-align: center; align-items: center; flex: 1; justify-content: center; pointer-events:none; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> <div class="wrapper"> <div id="containerOne" class="container"> <div class="name">Container One</div> </div> <div id="containerTwo" class="container"> <div class="name">Container Two</div> </div> <div id="containerThree" class="container"> <div class="name">Container Three</div> </div> <div id="containerFour" class="container"> <div class="name">Container Four</div> </div> </div>
user2076675
source share