首页 > 解决方案 > iframe 的问题

问题描述

我正在尝试将一个临时项目嵌入到 GitHub 页面中。我有一些代码:

<!DOCTYPE html><head><title>Project-Zero | OS-ONE</title><link rel="icon" href="https://raw.githubusercontent.com/OS-ONE/Project-Zero/main/image2.png" type="image/x-icon"/></head><iframe style="margin-top:-56px; margin-left:-11px;" allowtransparency="false" width="100%" height="108%" bgcolor=#220000 src="https://scratch.mit.edu/projects/embed/468188401/" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true"></iframe>

但由于某种原因,它显示如下: 图像 有没有办法解决这个问题?我见过其他人和我有同样问题的人,但由于某种原因它不起作用。提前致谢!

标签: htmliframe

解决方案


请尝试以像素为单位设置 with/height 并将 max-with:100% 设置为 iframe。

<!DOCTYPE html><head><title>Project-Zero | OS-ONE</title><link rel="icon" href="https://raw.githubusercontent.com/OS-ONE/Project-Zero/main/image2.png" type="image/x-icon"/></head><iframe style="max-width: 100%;" allowtransparency="false" width="1000" height="600" bgcolor=#220000 src="https://scratch.mit.edu/projects/embed/468188401/" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true"></iframe>

推荐阅读