html5 - Bootstrap - Horizontal Scrollbar -
i need horizontal scroll bar below code.
<!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <link href="bootstrap.min.css" rel="stylesheet" /> </head> <body> <h1 class="page-header">horizontal scroll in bootstrap</h1> <div class="container-fluid" style="overflow-x:scroll;"> <div class="col-sm-3"> <h3>tree 1</h3> </div> <div class="col-sm-3"> <h3>tree 2</h3> </div> <div class="col-sm-3"> <h3>tree 3</h3> </div> <div class="col-sm-3"> <h3>tree 4</h3> </div> <div class="col-sm-3"> <h3>tree 5</h3> </div> </div> </body> </html>
if executed above line output shown image. need tree 5 after tree 4. not below tree 1. if increase tree 6 shown after tree 5. i.e., need horizontal scrollbar. please me.
new answer
building on alex coloma's initial answer, lil clearer , without inline styles.
add following code custom css file , should trick:
@media (min-width: 992px) { .container-fluid { overflow-x: scroll; white-space: nowrap; } .col-md-3 { display: inline-block; vertical-align: top; float: none; } }
what , why work?
the .container-fluid part gives wrapper property scroll horizontally if there's overflowing content , tells not wrap ("linebreak") whitespace between text or in case child-elements.
the .col-md-3 part "hacks" bootstraps grid-system , disables floating left - responsible linebreak between fourth , fifth "tree". "display: inline-block" renders elements in 1 line , "vertical-align: top" makes may have guessed top-aligned.
problem
this "hack" renders bootstrap-grid pretty useless - @ least 3-column elements.
you may wanna give container additional class or id make new css target 1 container.
e.g.:
@media (min-width: 992px) { .container-fluid.my-own-class { overflow-x: scroll; white-space: nowrap; } .container-fluid.my-own-class .col-md-3 { display: inline-block; vertical-align: top; float: none; } }
and line in html this:
<div class="container-fluid my-own-class">
old answer
the main problem you're misunderstanding point of bootstrap grid-system. try wrap 15 columns (5 x col-3) in 12 column grid.
yeah, can that, have work around base principle of bootstrap kinda silly...
give little more precise information on wanna achieve, tried, demo, etc.
Comments
Post a Comment