From the course: Advanced Responsive Layouts with CSS Flexbox

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Hiding and showing the sidebar

Hiding and showing the sidebar - CSS Tutorial

From the course: Advanced Responsive Layouts with CSS Flexbox

Start my 1-month free trial

Hiding and showing the sidebar

- Changing the position of the sidebar, or re-ordering the content, or even changing the layout is all well and good, but sometimes you may want to hide the sidebar completely from view. I can think of a couple of instances where you may want to do that. For example, you may wanna create a function where if you start scrolling down the page, then the sidebar disappears and the content stays in the middle of the page so it's easier to read, and then if you scroll back up to the top, the sidebar reappears, or you could place your comments in a sidebar that only appears once you scroll to the bottom of an article. There are many different options here. Now the simple way of hiding the sidebar would be to simply append a class to the sidebar when a button is clicked that says display none, and then the sidebar would just disappear. But that's kinda crude because the sidebar would just go (snaps), and then it would be gone, and then you click on the button, and then (snaps) the sidebar…

Contents