Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Side bar buttons not wrapping to next line

I’m trying to make a sidebar and I tried to reuse the code for the bottom bar. The buttons wont wrap to the next line.

I tried changing the white-space hoping to fix the problem. The actual result was the buttons being stacked on top of each other.

.side-bar {
  position: fixed;
  left: 0;
  width: 55px;
  height: 100%;
  background-color: #000;
  display: flex;
  overflow-y: auto;
}

.s-btn {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  flex-grow: 1;
  min-height: 50px;
  overflow: hidden;
  white-space: nowrap;
  background: none;
  border: none;
  color: #fff;
}
<div class="main">
  <div class="side-bar">
    <button class="s-btn"><span class="material-symbols-outlined">
                    chat
                    </span></button>
    <button class="s-btn"><span class="material-symbols-outlined">
                    chat
                    </span></button>
    <button class="s-btn"><span class="material-symbols-outlined">
                    chat
                    </span></button>
    <button class="s-btn"><span class="material-symbols-outlined">
                    chat
                    </span></button>
  </div>
</div>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use flex-wrap: wrap or flex-direction: column on .side-bar class:

.side-bar {
    position: fixed;
    left: 0;
    width: 55px;
    height: 100%;
    background-color: #000;
    display: flex;
    flex-wrap: wrap; /* or flex-direction: column*/
    overflow-y: auto;
}

Flex wrap move the element to the next line whenever there’s no more space for it.

Flex direction columns stack the elements in column position

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading