Bootstrap Horizontal Scrolling


Answer :

It's okay to exceed 12 column units in a row. It causes the columns to wrap, but you can override the wrapping with flexbox.

Bootstrap 4 uses flexbox, and the utility classes to get a horizontal scrolling layout..

<div class="container-fluid">     <div class="row flex-row flex-nowrap">         <div class="col-3">            ..         </div>         <div class="col-3">            ..         </div>         <div class="col-3">            ..         </div>         <div class="col-3">            ..         </div>         <div class="col-3">            ..         </div>         <div class="col-3">            ..         </div>         <div class="col-3">            ..         </div>         <div class="col-3">            ..         </div>     </div> </div> 

Bootstrap 4 Demo: http://codeply.com/go/GoFQqQAFhN

Also see: Horizontally scrollable list of cards in Bootstrap

For Bootstrap 3, it would be done with some CSS for the flexbox.. .

row > .col-xs-3 {     display:flex;     flex: 0 0 25%;     max-width: 25% }  .flex-nowrap {     -webkit-flex-wrap: nowrap!important;     -ms-flex-wrap: nowrap!important;     flex-wrap: nowrap!important; } .flex-row {     display:flex;     -webkit-box-orient: horizontal!important;     -webkit-box-direction: normal!important;     -webkit-flex-direction: row!important;     -ms-flex-direction: row!important;     flex-direction: row!important; } 

Bootstrap 3 Demo: http://codeply.com/go/P13J3LuBIM


One other way :

CSS:

#list .row {white-space:nowrap;} #list .row > div {display:inline-block;float:none;} 

Js for horizontal scrolling:

window.addEventListener('mousewheel', function(e){     e.preventDefault();     var step = -100;       if (e.wheelDelta < 0) {       step *= -1;     }     var newPos = window.pageXOffset + step;     $('body').scrollLeft(newPos);     }) 

Bootply : https://www.bootply.com/pbenard/usmX12rxgP


Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable