Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make horizontal scroll on page

I have div in which placed inner divs i need to make all inner divs in line and horizontal scrollbar should be displayed (i know it sounds crazy, but i need that). I tried container width auto and overflow scroll but nothing.

How to accomplish that?

my markup:

   <!DOCTYPE html>
<html>
 <head>
  <meta charset="utf-8">
  <title>text-overflow</title>
  <style>
  body{
    width: auto;
  }
  #items{
  overflow-x: scroll;
  width: auto;
  }
  .item{
     display: inline-block;
     width: 400px;
     height: 100px;
     border:1px solid;
  }
  </style>
 </head>
 <body>

        <div id="items">
           <div class="item">
             Item content
           </div>
           <div class="item">
             Item content
           </div>
           <div class="item">
             Item content
           </div>
           <div class="item">
             Item content
           </div>
           <div class="item">
             Item content
           </div>
           <div class="item">
             Item content
           </div>
        </div>

 </body>
</html>
like image 373
testCoder Avatar asked Nov 14 '12 12:11

testCoder


People also ask

How do I make my page horizontally scrollable?

Horizontal scrolling can be achieved by clicking and dragging a horizontal scroll bar, swiping sideways on a desktop trackpad or trackpad mouse, pressing left and right arrow keys, or swiping sideways with one's finger on a touchscreen.

How do I add a horizontal scroll bar in Word?

Click on Advanced. Scroll down to the Display section in the list of options displayed. Put a check mark next to all scroll bar options: "Show horizontal scroll bar," "Show vertical scroll bar" and "Show vertical scroll bar in Print Layout view."


1 Answers

Use white-space: nowrap; on #items

#items{
    overflow-x: scroll;
    width: auto;
    white-space: nowrap;
}

DEMO

like image 191
Zoltan Toth Avatar answered Oct 18 '22 19:10

Zoltan Toth