【问题标题】:Cannot center Java Applet in HTML file无法在 HTML 文件中居中 Java Applet
【发布时间】:2015-02-05 04:23:29
【问题描述】:

我需要将我的小程序水平和垂直居中,但我只能将它水平居中。任何人都可以帮助解决这个简单的 CSS 问题吗?我试过使用“显示:内联块;”和“显示:块;”但这两者都没有效果。这是我的代码:

<!DOCTYPE html>
<html>
    <head>
        <title>testing..</title>    
        <style type="text/css">
            html, body {
                margin: 0;
            }
            #container {
                width: 640px;
                height: 610px;              
                margin: auto;
            }
        </style>
    </head>
    <body>
        <div id="container">
            <applet code="TetrisApplet.class" width="640" height="610"/>
        </div>
    </body>
</html>

【问题讨论】:

    标签: html css applet center margin


    【解决方案1】:

    您可以使用相同宽度的 div 和 applet 或将小程序放入新的 div 宽度 display:inline-block;

    【讨论】:

    • 谢谢,我把它水平居中,现在它卡在了顶部。我现在只需要将它垂直居中。这有帮助:)
    • 6种CSS垂直居中方法vanseodesign.com/css/vertical-centering
    • 谢谢,只有“绝对定位和负边距”方法有效:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-21
    • 1970-01-01
    • 1970-01-01
    • 2018-03-12
    相关资源
    最近更新 更多