2

I'm currently trying to make a sidebar layout work. I feel like I'm nearly there but the last bit is just not working.

html,body {
  width: 100%;
  height: 100%;
}

#wrapper {
  display: flex;
  width: 100%;
  height: 100%;
}

.sidebar {
  height: 100%;
  position: fixed;
  width: 200px;
  background: red;
  overflow: auto;
  flex-direction: column;
  display: flex;
}

ul {
  padding: 0;
  margin: 0;
}

.menu {
  flex: 1;
  background: rgb(150,0,0);
}

.users {
   overflow: auto;
   max-height: 240px;
   min-height: 100px;
}
<div id="wrapper">
  <div class="sidebar">
    <ul class="menu">
      <li>item 1</li>
      <li>item 2</li>
      <li>item 3</li>
      <li>item 4</li>
      <li>item 5</li>
    </ul>
    <ul class="users">
      <li>user 1</li>
      <li>user 2</li>
      <li>user 3</li>
    </ul>
  </div>
  <div class="content">
    
  </div>
</div>

Here is a fiddle of the layout which works better to see the issue than the above snippet: https://jsfiddle.net/ybp4og8w/1/

All works great except when the height of the window gets really small, smaller than the menu items list. The content at the bottom disappears off screen. Ideally I'd like to have the user list sticky at the bottom (which is correct right now but I've also had this issue when messing with the code), not overlap the menu items when the height gets small but instead make the sidebar become scroll-able.

Any tips on how to achieve this?

1 Answer 1

2

I see your jsfiddle and apply this code in #sidebar

overflow-y:scroll;

May be this helpful.

Thanks!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.