简体   繁体   中英

Prevent HTML <img> tags from Wrapping

I have JavaScript that dynamically creates many <img> tags and appends them to various divs.

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

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.

in CSS

div {
 overflow: auto;
}

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