How to make horizontal scrollable in a bootstrap row?
Here is the task to make horizontally scrollable in a bootstrap row.
It can be done by the following approach:
Approach:
- Making all the div element in inline using display: inline-block; property
- Adding the scroll bar to all the div element using overflow-x: auto; property.
- white-space: nowrap; property is used make all div in a single line.
Example :
<!DOCTYPE html> <html lang="en"> <head> <title>How to make horizontal scrollable in a bootstrap row?</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href= <style> /* The heart of the matter */ .horizontal-scrollable > .row { overflow-x: auto; white-space: nowrap; } .horizontal-scrollable > .row > .col-xs-4 { display: inline-block; float: none; } /* Decorations */ .col-xs-4 { color: white; font-size: 24px; padding-bottom: 20px; padding-top: 18px; } .col-xs-4:nth-child(2n+1) { background: green; } .col-xs-4:nth-child(2n+2) { background: black; } </style> </head> <body> <center> <div class="container"> <h1 style="text-align:center;color:green;"> GeeksforGeeks </h1> <h3> To make horizontal scrollable in a bootstrap row? </h3> <div class="container horizontal-scrollable"> <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> </div> </div> </center> </body> </html> |
chevron_right
filter_none
Output:

Recommended Posts:
- How to set horizontal aligned accordion in Bootstrap 4 ?
- How to display multiple horizontal images in Bootstrap card ?
- How to fixed one column and scrollable other column or columns in Bootstrap ?
- How to make horizontal line with words in the middle using CSS?
- How to make a div fill a remaining horizontal space using CSS?
- Bootstrap (Part-4) | Vertical Forms, Horizontal Forms, Inline Forms
- How to make bootstrap button transparent ?
- How to make whole row in a table clickable as link in Bootstrap ?
- How to make a Bootstrap 4 accordion collapse when clicking the whole header div ?
- How to make Bootstrap popover appear/disappear on hover instead of click?
- How to make Bootstrap table with sticky table head?
- Making a div vertically scrollable using CSS
- Difference between bootstrap.css and bootstrap-theme.css
- Include Bootstrap in AngularJS using ng-bootstrap
- Difference Between Bootstrap 3 and Bootstrap 4
- CSS | Layout - Horizontal & Vertical Align
- How to set horizontal skew of a canvas circle using Fabric.js ?
- How to lock horizontal movement of a canvas circle using Fabric.js ?
- How to lock horizontal scaling of a text canvas using Fabric.js ?
- How to lock the horizontal movement of a canvas text using Fabric.js ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Akanksha_Rai

