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

How to make overflowing div to go to bottom when max-width is reached?

How to make overflowing div to go bottom, when width of parent div is filled. here tag 7 and 8 is overflowing. How to make it go bottom when there is no more space available? Thank you

.main{
  width: 300px;
  height: 150px;
  display:flex;
  border: 2px solid #000;
  padding: 10px;
}

.inner{
  border: 1px solid #5eba7d;
  margin-right:5px;
  padding: 5px;
  height: max-content;
  width: max-content;
  white-space:nowrap;
}
<div class="main">
 <div class="inner">tag 1</div>
 <div class="inner">tag 2</div>
 <div class="inner">tag 3</div>
 <div class="inner">tag 4</div>
 <div class="inner">tag 5</div>
 <div class="inner">tag 6</div>
 <div class="inner">tag 7</div>
 <div class="inner">tag 8</div>
</div>

>Solution :

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

Just add flex-wrap property to the parent element and it should do the trick.

.main{
  width: 300px;
  height: 150px;
  display:flex;
  border: 2px solid #000;
  padding: 10px;
  flex-wrap: wrap;
}

.inner{
  border: 1px solid #5eba7d;
  margin-right:5px;
  padding: 5px;
  height: max-content;
  width: max-content;
  white-space:nowrap;
}
<div class="main">
 <div class="inner">tag 1</div>
 <div class="inner">tag 2</div>
 <div class="inner">tag 3</div>
 <div class="inner">tag 4</div>
 <div class="inner">tag 5</div>
 <div class="inner">tag 6</div>
 <div class="inner">tag 7</div>
 <div class="inner">tag 8</div>
</div>
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