HTML CSS examples for CSS Layout:Flex
Collapsible flexible-width sidebar using only CSS via transform animation
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style id="compiled-css" type="text/css"> body {<!--from www . jav a2 s. com--> margin:0; } .container { display:flex; } .sidebar { background:Chartreuse; transition:all .2s; } .sidebar.collapsed { transform:translateX(-100%); position:absolute; } </style> </head> <body> <div class="container"> <div class="sidebar" id="sidebar"> <div> SIDEBAR </div> </div> <div class="content"> lorem bla bla <button onclick="document.getElementsByClassName('sidebar')[0].classList.toggle('collapsed')">toggle Sidebar</button> </div> </div> </body> </html>