Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css horizontal scrolling with bootstrap using ul li tags

I'm trying to horizontal scroll using bootstrap, but I'm not able to get it to scroll horizontally. My li tags just doesn't wrap the way it should (it's wrapping normally).

HTML:

<div class="container suggest">
  <ul class="thumbnails bsuggest" >
    <li class="span2">
     text goes here
    </li>
  </ul>
</div>

CSS:

.bsuggest
{
    overflow-x:scroll;
    overflow-y:hidden;
    height:250px;
    white-space:nowrap; !important
    width:100%;
}
.bsuggest li
{
    float:left;
    display:inline-block;
    *dsplay:inline;/* For IE7*/
    *zoom:1;/* For IE7*/
    white-space:normal;
}
.suggest
{
    width:100%;
    position:relative;
    margin-top:95px;
}

I think I've done what its supposed to?

like image 743
hellomello Avatar asked Dec 16 '12 23:12

hellomello


People also ask

How do I horizontally scroll in CSS?

To enable horizontal scrolling, we can use the CSS property overflow-x. If we assign the value scroll to the overflow-x property of the container element, the browser will hide horizontally overflowing content and make it accessible via horizontal scrolling.

How do I make a horizontal scrolling image in HTML?

The scrolling images were acheived using the HTML <marquee> tag. Using this tag, you can give your images a horizontal scroll (from right to left, left to right) or a vertical scroll (top to bottom, or bottom to top). Note that the <marquee> tag isn't an offical HTML tag (but it is recognized by most modern browsers).

How do I fix the horizontal scroll bar in HTML?

To hide the horizontal scrollbar and prevent horizontal scrolling, use overflow-x: hidden: HTML.


2 Answers

In Bootstrap 2 you have to overwrite some span* styling.

The ul element has to get this css:

ul.your-horizontal-list {
    white-space: nowrap;
    overflow-x: auto;
}

ul.your-horizontal-list li[class*="span"] {
    display: inline-block;
    float: none;
}

Here is an working demo.

Make sure that your CSS is loaded after the bootstrap CSS.

EDIT: Name it Bootstrap 2, in Bootstrap 3 you probably need to replace span with col-... or something similar.

like image 110
adriaan Avatar answered Oct 06 '22 06:10

adriaan


On the line white-space:nowrap; !important in .bsuggest the !important needs to be before the ;

Like so white-space:nowrap !important;

like image 41
dev Avatar answered Oct 06 '22 06:10

dev