简体   繁体   中英

Div with constant height variable width

There is a Div of width say 500px and height 50px. Inside this Div there are many (say 50) small Div of width 50px and height 50 px. Now i want a horizontal scroll instead of a vertical one. How can i force those small divs to overflow horizontally not vertically

Also number of small divs can change.

Assign the following CSS to the outer DIV :

white-space: nowrap;
overflow-x: scroll;

See an example at this fiddle .

Try setting the child div's to display: inline-block , then set the parent to white-space: nowrap .

Hope that helps :)

the main div style define

 float : left; 
 overflow : scroll;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM