The code presented in this page shows you how to make DIV contents scroll horizontally, with multiple Div's inside aligned horizontally.
To create this design, sets these CSS properties to container DIV:
      - a fixed width and height.
      - white-space: nowrap; to keep the contents on the same line; to not go to a new row.
      - overflow-x: auto; - to display the horizontal scroll bar when the contents exceeds container width.
      - overflow-y: hidden; - optional, to not display the vertical scroll bar.

And add these CSS properties the children DIV's:
      - display: inline-block; - to align the DIV's horizontally.
      - white-space: normal; - to anulate the "nowrap" inherited from parent (container) DIV.

Here is an example.
<!doctype html>
<html lang="en">
<meta charset="utf-8" />
<title>Example Making DIV Contents Scroll Horizontally, width multiple Div`s inside</title>
<style type="text/css">
#container {
  position: relative;
  height: 9em;
  width: 99%;
  margin: 2px auto;
  background: #abefcd;
  text-align: left;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
#container div {
  display: inline-block;
  width: 14em;
  height: 6em;
  margin: 0.5em;
  border: 1px solid blue;
  padding: 3px;
  white-space: normal;
  text-align: center;

<div id="container">
 <div>Content in Div 1:<br/> Web Development courses</div>
 <div>Div 2<br/></div>
 <div>Div 3<br/></div>
 <div><img src="some_image" width="99" height="36" alt="Image Text" /></div>
 <div>Div 5<br/></div>

Content in Div 1:
Web Development courses
Div 2
Div 3
Image Text
Div 5

To have the Div`s inside container aligned perfectly, their content must have the same number of rows.

Daily Test with Code Example

Which tag is used in <table> to create table header cell?
<thead> <th> <td>
  <th>Title 1</th>
  <th>Title 2</th>
Which CSS property sets the distance between lines?
line-height word-spacing margin
.some_class {
  line-height: 150%;
Which function opens a new browser window.
alert() confirm() open()
document.getElementById("id_button").onclick = function(){"");
Indicate the PHP function that returns an array with names of the files and folders inside a directory.
mkdir() scandir() readdir()
$ar_dir = scandir("dir_name");
Making DIV Contents Scroll Horizontally, with multiple Div`s inside

Last accessed pages

  1. Qwop (22515)
  2. Mahjong Gardens (4846)
  3. Bubble Hit (1523)
  4. Dog Mahjong (4116)
  5. Introduction to Adobe Flash (1737)

Popular pages this month

  1. Bubbles3 (3702)
  2. Butterfly Kyodai (2804)
  3. Zuma Deluxe (2375)
  4. Backgammon (1425)
  5. Qwop (1374)