I've noticed several inquiries on this platform regarding how to close a drop-down menu by clicking anywhere outside of it.
However, my question is a bit different. I want the dropdown-menu to remain open once clicked, only closing when the user clicks on the button again. Additionally, when the menu is displayed, I want it to push other elements directly beneath it down, such as other buttons. This concept can be seen on various websites and I find it intriguing. I would like to implement something similar but I'm unsure where to start.
This functionality will most likely be achieved with Javascript for simplicity, but I lack the knowledge on how to execute it. Do you have any suggestions or tips?
Your help would be greatly appreciated. Thank you in advance.
Edit: To provide an example of what I mean: Link to jsfiddle ->
https://jsfiddle.net/Cerebrl/uhykY/
I aim to move buttons 2 and 3 downward as soon as the first menu is expanded, creating its own space for display. Furthermore, I intend for the menu to only close upon button click, not by clicking outside of it.