@James-alderson
Posted
Hi David, the challenge you designed is very nice and well designed, there are just a few points that would help improve your design.
- Give the transition to the element itself, not to the floating element, because then when the mouse leaves the element, it will return to the original state in an animation. (rating__input button and .rating__btns).
- For ranks, it is better to use width and height, because in this case, there is no need to adjust the layer value to make it square, and if the numbers inside the ranks become two or three digits in the future, there is no need to change the padding value again.
- The centering of the element on the page is done correctly, but it is not correctly centered in high resolutions. For this reason, it is better to use the grid method to center the element. Use these styles in your body element: (display: grid, height: 100vh, place-items: center;) and remove these styles from your .rating element: (height: 100%; margin: 20vh auto;).
/////////////////////////////////////
To answer your question, currently I can't do this with css and javascript, instead you can use the max-height attribute to create the animation.
Of course, there is a solution for your question, and that is using the jQuery library. Example of jQuery: jQuery Animated Accordion. When you click on the accordion title, you can see the conditions for changing the .content element using the web developer tool.
Marked as helpful