将网页内容限制在固定大小内
我有一段html。我想将该 html 嵌入到我自己网页上的一对标签中。 html 代码事先并不知道。它是动态获得的。该 html 代码可以包含任何内容,通常是图像和文本以及 YouTube 视频。
问题是我想将内容嵌入固定大小。大小用宽度和高度(以像素为单位)指定。如果内容有大图像,我想以相同的系数调整图像以及其他内容的大小,以便整个内容可以适合指定的大小。一切仍然按比例进行。
我也不想要滚动条。我不知道该怎么做。我对 html 很熟悉,但对 CSS 不太了解。我在网上搜索过,试图找到其他人实现此功能的示例。我找不到任何。
你知道怎么做吗?
I have a piece of html. i want to embed that html into a pair of tags on my own web page. the html code is not known in advance. it is obtained dynamically. this html code can contain anything, normally images and texts and youtube videos.
the problem is that i want to embed the content into a fix size . the size is specified with width and height in pixels. if the content has large images, i want to resize the image as well as other content with a same factor such that the whole content can fit into the specified size. everything is still in proportion.
i don't want scrollbar either. i don't know how to do this. I'm familiar with html but not much with CSS. I have searched the web trying to find examples of other people implement this. I couldn't find any.
do you know how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
忘记这一点。它无法可靠地处理任意内容。
您可以将所有内容放入容器中:
然后尝试对其中的图像强制设置最大宽度:
但不要指望它总是看起来很漂亮。
目前还没有办法真正缩放 DIV 或 IFrame 内的内容。
Forget this. It's not going to work reliably for arbitrary content.
You can put everything into a container:
and then try to force a
max-width
on images therein:but don't expect that it'll always look pretty.
There is no way to really zoom content inside a DIV or IFrame (yet).