Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Horizontal scrollable div's in a bootstrap row

I'm trying the make a horizontal scrollable bootstrap row. The row contains customer reviews wrapped in div's. The width of each testimonial div is 33.333%.

white-space: nowrap and display: inline-block doesn't work.

What am I doing wrong?

<div class="row">     <div class="col-lg-12 text-center">         <div class="section-title">            <div class="testimonial_group">                <div class="testimonial">...</div>                <div class="testimonial">...</div>                <div class="testimonial">...</div>                <div class="testimonial">...</div>                ...            </div>         </div>     </div> </div> 
like image 875
Codehan25 Avatar asked Aug 11 '16 15:08

Codehan25


People also ask

How do I make my element horizontally scrollable?

For horizontal scrollable bar use the x and y-axis. Set the overflow-y: hidden; and overflow-x: auto; that will automatically hide the vertical scroll bar and present only the horizontal scrollbar. The white-space: nowrap; property is used to wrap text in a single line.

How do you make a row scrollable in CSS?

you don't need it to be overflow-x just make it overflow: scroll; . Just do this in the td element. Also, the content has to be long enough to scroll the element.

How do I make vertical scrolling rows in bootstrap?

It can be done by the following approach: Approach: Making all the div element in next line using position: absolute; property (arrange all div column-wise). Adding the scroll bar to all the div element using overflow-y: scroll; property.

How do I add a horizontal scrollbar?

Basic Horizontal Scroll Box To make a scroll box with a horizontal scroll, you need to use the overflow-x property. Specifically, you need to use this code: overflow-x:scroll; . This tells your browser to create scroll bars on the x (horizontal) axis, whenever the contents of the container is too wide.


1 Answers

Please check. Is it what you want to achieve?

horizontal scrolling

CodePen  •  JSFiddle

/* The heart of the matter */ .testimonial-group > .row {   overflow-x: auto;   white-space: nowrap; } .testimonial-group > .row > .col-xs-4 {   display: inline-block;   float: none; }  /* Decorations */ .col-xs-4 { color: #fff; font-size: 48px; padding-bottom: 20px; padding-top: 18px; } .col-xs-4:nth-child(3n+1) { background: #c69; } .col-xs-4:nth-child(3n+2) { background: #9c6; } .col-xs-4:nth-child(3n+3) { background: #69c; }
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">  <div class="container testimonial-group">   <div class="row text-center">     <div class="col-xs-4">1</div><!--  --><div class="col-xs-4">2</div><!--  --><div class="col-xs-4">3</div><!--  --><div class="col-xs-4">4</div><!--  --><div class="col-xs-4">5</div><!--  --><div class="col-xs-4">6</div><!--  --><div class="col-xs-4">7</div><!--  --><div class="col-xs-4">8</div><!--  --><div class="col-xs-4">9</div>   </div> </div>

for Bootstrap 4

Thanks Hector for the comment!

https://codepen.io/glebkema/pen/xxOgaMm

/* The heart of the matter */ .testimonial-group > .row {   display: block;   overflow-x: auto;   white-space: nowrap; } .testimonial-group > .row > .col-4 {   display: inline-block; }  /* Decorations */ .col-4 { color: #fff; font-size: 48px; padding-bottom: 20px; padding-top: 18px; } .col-4:nth-child(3n+1) { background: #c69; } .col-4:nth-child(3n+2) { background: #9c6; } .col-4:nth-child(3n+3) { background: #69c; }
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css">  <div class="container testimonial-group">   <div class="row text-center">     <div class="col-4">1</div><!--  --><div class="col-4">2</div><!--  --><div class="col-4">3</div><!--  --><div class="col-4">4</div><!--  --><div class="col-4">5</div><!--  --><div class="col-4">6</div><!--  --><div class="col-4">7</div><!--  --><div class="col-4">8</div><!--  --><div class="col-4">9</div>   </div> </div>
like image 130
Gleb Kemarsky Avatar answered Sep 21 '22 04:09

Gleb Kemarsky