调整窗口大小时,将下表中的图像调整为 100%
我认为类似的问题已经得到解答,但似乎没有一个真正对我有帮助。
我有一个设置为 width="100%"
的表格,其中顶行有一个单元格。 该单元格包含一个相当宽的图像。 当我调整窗口大小以及表格大小时,图像的大小不会调整到低于其原始大小的 100%。
有没有办法让该图像随着表格缩小而缩小?
I think similar questions have been answered, but none really seem to have helped me out that much.
I have a table that is set to width="100%"
with a cell on the top row.
This cell contains an image which is fairly wide.
When I resize the window, and therefore the table, the image does not resize below 100% of its original size.
Is there a way to get this image to reduce in size as the table shrinks?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将图像宽度也设置为 100%。
如果这没有帮助将其设置为自动!
或者
Set image width to 100% as well.
If this doesn't help set it to auto!
or
如果您希望它实际上变得小于图像的指定宽度/高度(或原始宽度/高度),则需要执行一些脚本编写。这意味着您可以挂接浏览器的调整大小事件,并在调整大小时均匀地重置图像的宽度/高度。
另一种选择是将图像包装在 div 中,并指定溢出:隐藏。因此,如果 div 对于窗口来说太大,它将隐藏窗口之外的图像片段。
If you want it to actually get smaller than the specified width/height (or the original width/height) of the image, you need to do some scripting. This means you can hook up the resize event of the browser and reset the width/height of the image equally while resizing.
Another option is to wrap the image in a div with an overflow:hidden specified. So if the div gets to large for the window, it will hide the pieces of the image that fall outside the window.