4

I know how bootstrap 4 is working with col instead of col-xs but the issue I am facing is that when the text within the column is too long to accommodate on a small screen device, the columns start to stack below each other. Is there any way to prevent this and fix the col width to 1/5 of the screen and just cut off the extra text. Try the below code and compress your browser width.

<div class="container-fluid">
<div class="row">
    <div class="col">some loong loong loong loong loong text</div>
    <div class="col">some loong loong loong loong loong text</div>
    <div class="col">some loong loong loong loong loong text</div>
    <div class="col">some loong loong loong loong loong text</div>
    <div class="col">some loong loong loong loong loong text</div>
</div>

Carol Skelly
  • 351,302
  • 90
  • 710
  • 624
rrchrga
  • 55
  • 1
  • 6

2 Answers2

4

You can use the text-truncate class. This will prevent the text inside the columns from wrapping and use ellipsis (...) when the text is too long.

https://www.codeply.com/go/rGFZfVlidi

<div class="container-fluid">
    <div class="row">
        <div class="col text-truncate">some loong loong loong loong loong text</div>
        <div class="col text-truncate">some loong loong loong loong loong text</div>
        <div class="col text-truncate">some loong loong loong loong loong text</div>
        <div class="col text-truncate">some loong loong loong loong loong text</div>
        <div class="col text-truncate">some loong loong loong loong loong text</div>
    </div>
</div>

Alternatively, text-nowrap could be used if you don't want .... Read more on text wrapping and overflow in Bootstrap 4.

Carol Skelly
  • 351,302
  • 90
  • 710
  • 624
3

You can avoid the wrap by add flex-nowrap

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" >
<div class="container-fluid">
  <div class="row flex-nowrap">
    <div class="col">some loong loong loong loong loong text</div>
    <div class="col">some loong loong loong loong loong text</div>
    <div class="col">some loong loong loong loong loong text</div>
    <div class="col">some loong loong loong loong loong text</div>
    <div class="col">some loong loong loong loong loong text</div>
  </div>
</div>
Temani Afif
  • 245,468
  • 26
  • 309
  • 415