开发者

Prevent HTML <img> tags from Wrapping

开发者 https://www.devze.com 2022-12-31 08:57 出处:网络
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, wh开发者_Go百科en the screen resolution is no

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, wh开发者_Go百科en 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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消