views:

51

answers:

2

Hi all, I have a javascript that dynamically creates many <img> tags, and appends them to various divs.

I want to prevent these images from wrapping; when the screen resolution is not enough to contain them the browser should create horizontal scroll-bars.

Sorry for this bad English.

+1  A: 

in CSS

div {
 overflow: auto;
}
John Hartsock
It's worth noting that this doesn't *strictly* observe the specific requirement of *horizontal scroll-bars*, `overflow-x: auto` might be better. But I'm not sure if the OP *meant* to specify only horizontal scroll-bars, or not.
David Thomas
Adding only this property, doesn't work.
ILCARTOLAiO
+2  A: 

Add the following CSS to the div containing the img tags:
overflow-x: auto; white-space: nowrap;
in order to get a horizontal scrollbar when the content is wider than the div and to prevent the content from wrapping.

mVChr
I have many of these divs, so this works, but i have to set it only on the "container" div.Thank you.
ILCARTOLAiO