大家下午好
我有一个 Java 小程序,我希望将其嵌入网站。我要求小程序是全尺寸,即它占据网页的 100% 宽度和 100% 高度。
不应该有滚动条。
这是我目前拥有的代码:
<!doctype html>
<html>
<body style="background:red; width:100%; height:100%; padding:0; margin:0; border:0;">
<applet code="HelloWorld.class" style="padding:0; margin:0; border:0; width:100%; height:100%;">
Your browser does not support the <code>applet</code> tag.
</applet>
<!-- the applet should cover the entire page, so even though the body is red, it should be covered by the applet -->
</body>
</html>
出于某种原因,它不适用于 FireFox 和 IE。在 Chrome 中,小程序看起来比页面本身高,因此会显示垂直滚动条。我们如何使小程序完全填充网页的大小,既不显示任何水平滚动条,也不显示垂直滚动条?
PS:如果可能,在禁用 JavaScript 的浏览器上运行的解决方案会很酷。
最佳答案
使用绝对位置。不要指定高度或宽度。
applet {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
关于java - "full-page"小程序的 HTML 代码(无 javascript)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9985755/