DIV宽度和高度在设置innerHTML时不会调整大小?

编程入门 行业动态 更新时间:2024-10-10 03:22:37
本文介绍了DIV宽度和高度在设置innerHTML时不会调整大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我将图像设置为DIV容器的innerHTML时,DIV的宽度和高度仍未更改。 div有 border:solid 样式,边框就像图片的外部一样... ...

图像显示完整,但它伸展在div边界之外,但仍然显示。这是一个问题吗?

我应该使用DOM方法吗?

谢谢

解决方案

您是否设置了div的溢出 css属性?

www.w3schools/Css/pr_pos_overflow.asp

When I set an image to the innerHTML of a DIV container, the width and height of the DIV is still not changed. The div has border:solid style and the border is like "outside" the image...

So the image is shown fully, but it streches outside the div borders, but still shows anyway. Is this a problem ?

Should I use the DOM method instead, will it be better ?

Thanks

解决方案

have you set the overflow css property of your div ?

www.w3schools/Css/pr_pos_overflow.asp

更多推荐

DIV宽度和高度在设置innerHTML时不会调整大小?

本文发布于:2023-07-09 21:03:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1088201.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:宽度   高度   大小   DIV   innerHTML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!