简体   繁体   English

防止HTML <img> 包装标签

[英]Prevent HTML <img> tags from Wrapping

I have JavaScript that dynamically creates many <img> tags and appends them to various divs. 我有JavaScript,可以动态创建许多<img>标记并将其附加到各个div。

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: 将以下CSS添加到包含img标签的div中:
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. 为了在内容大于div时获得水平滚动条并防止内容换行。

in CSS 在CSS中

div {
 overflow: auto;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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