【问题标题】:HTML / CSS height issue with IEIE 的 HTML / CSS 高度问题
【发布时间】:2015-07-27 12:30:23
【问题描述】:

我正在尝试更新 pfSense 强制门户身份验证页面,它在任何地方都显示良好除了 IE(桌面版和移动版)。问题是上表行(来自 2 行表)正在扩展到大尺寸,如下图所示。 HTML 是:

    <html> 
<link rel="stylesheet" type="text/css" href="style.css">
<body> 
<form method="post" action="#PORTAL_ACTION#" align="center" > 
    <input name="redirurl" type="hidden" value="#PORTAL_REDIRURL#">
    <input name="zone" type="hidden" value="#PORTAL_ZONE#">
    <center>
    <table class="MainTable">
    <!--Beginning of Form title heading-->
        <tr class="TableTopRow">
            <td class="TableTopCell1">
                <img src="captiveportal-wifi_icon.png" width="50%" height="3%" align="right">
            </td>
            <td class="TableTopCell2" >
                <img src="captiveportal-aragon_logo.png" width="50%" height="3%" align="left">
            </td>
        </tr>
    <!--End of Form title heading-->
    <!--Beginning of main area which contains authentication form and an area reserved for showing errors-->
        <tr class="TableLowerRow" colspan="2" height="70%">
            <td colspan="2" width="100%">
                <div id="mainlevel">
                <center>
                <table height="100%" width="100%" border="0" cellpadding="0">
                    <tr> 
                        <td style="color:#0B173B;font-family:arial; font-weight:bold; font-size:90%"><center>
                            Welcome to Aragon House Business Center
                        </td>
                    </tr>
                <tr>
                    <td>
                        <center>
                        <div id="mainarea">
                        <center>
                        <table width="100%" border="0" cellpadding="1px" cellspacing="2">
                        <tr  height="20%">
                            <td>
                                <div id="maindivarea">
                                <center>
                                    <!-- The statusbox area is where errors will be shown should there be an error when authenticating with the hotspot-->
                                    <div id='statusbox'>
                                        <font color='red' face='arial' size='+1'>
                                        <b>
                                            #PORTAL_MESSAGE#
                                        </b>
                                        </font>
                                    </div>
                                    <!--End of error message area-->
                                    <br />
                                    <!--Beginning of form area; this area will contain fields for authenticating users with the hotspot system-->
                                    <div id='loginbox'>
                                    <table>
                                        <!-- Beginning of area where you input the authentication details-->

                                        <tr><td>&nbsp;</td></tr>
                                        <tr><td align="right" style="color:#333333;font-family:arial; font-size:98%;">Username:</td><td><input name="auth_user" type="text" style="border: 1px solid;"></td></tr>
                                        <tr><td align="right" style="color:#333333;font-family:arial; font-size:98%;">Password:</td><td><input name="auth_pass" type="password" style="border: 1px solid;"></td></tr>
                                        <tr><td>&nbsp;</td></tr>
                                        <tr>
                                            <td align="right" style="color:#333333;font-family:arial; font-size:98%;">Enter Voucher Code: </td>
                                            <td><input name="auth_voucher" type="text" style="border:1px solid;" size="20"></td>
                                        </tr>
                                        <tr>
                                            <td colspan="2" align="right" style="padding-right:10px"><input name="accept" type="submit" value="Continue"></td>
                                        </tr>
                                        <!-- End of area where you input the authentication details-->
                                    </table>
                                    </div>
                                    <!--End of  authentication form area-->
                                </center>
                                </div>
                            </td>
                        </tr>
                        </table>
                        </center>
                        </div>
                        </center>
                    </td>
                </tr>
                </table>
                </center>
                </div>
            </td>
        </tr>
    </table>
    </center>
    <!--End of main area-->
</form>
</body> 
</html>

虽然 CSS 是:

    .MainTable{
    height: 40%;
    width: 30%;
    padding: 0;
    border-radius: 15px;
    border:1px solid #000000;
}

.TableTopRow{
    width: 30%;
    height: 30%;
    background-color:#CCCCCC;
    border-top-right-radius: 15px; 
    border-top-left-radius: 15px; 
    border-top:1px #6DA4DE; 
}

.TableLowerRow{
    height: 70%;    
}

.TableTopCell1{
    width: 50%;
    border-top-left-radius: 15px;
}
.TableTopCell2{
    width: 50%;
    border-top-right-radius: 15px;
}

第一张图片显示了表单在 IE 中的显示方式,而下图显示了相同表单在 Chrome 中的显示方式。

非常感谢您的帮助。

提前致谢, J

【问题讨论】:

  • 哪个版本的 IE ?对于 IE 11 它运行良好 jsfiddle.net/fqzfbw39
  • @SrinivasPai- 我使用的是版本 11,但是我尝试使用 IE 11 复制 jsfiddle 上的问题,就像您所做的那样,它运行良好。当我尝试在实际浏览器中打开它时,它无法按预期加载。

标签: html css internet-explorer pfsense


【解决方案1】:

您有 6 个开启 &lt;center&gt;5 个关闭 &lt;/center&gt; 。可能 IE 不够聪明,无法为您正确关闭它:D

【讨论】:

    【解决方案2】:

    Why your css might not be working

    添加display: inline; 通常会在 IE 中修复这些错误,具体取决于您使用的版本

    您还缺少一个文档类型,它修复了 IE 中的许多问题 Quirksmode IE CSS Fix

    把它放在你的html页面的顶部

    <!DOCTYPE html>
    

    虽然我们正在处理这样的事情,但您应该将您的 css 放在外部文件中,而不是混合和匹配。在这个时代,使用表格进行造型是一种不好的做法

    <div id='loginbox'>
       <table>
          <!-- Beginning of area where you input the authentication details-->
          <tr>
             <td>&nbsp;</td>
          </tr>
          <tr>
             <td align="right" style="color:#333333;font-family:arial; font-size:98%;">Username:</td>
             <td><input name="auth_user" type="text" style="border: 1px solid;"></td>
          </tr>
          <tr>
             <td align="right" style="color:#333333;font-family:arial; font-size:98%;">Password:</td>
             <td><input name="auth_pass" type="password" style="border: 1px solid;"></td>
          </tr>
          <tr>
             <td>&nbsp;</td>
          </tr>
          <tr>
             <td align="right" style="color:#333333;font-family:arial; font-size:98%;">Enter Voucher Code: </td>
             <td><input name="auth_voucher" type="text" style="border:1px solid;" size="20"></td>
          </tr>
          <tr>
             <td colspan="2" align="right" style="padding-right:10px"><input name="accept" type="submit" value="Continue"></td>
          </tr>
          <!-- End of area where you input the authentication details-->
       </table>
    </div>
    

    【讨论】:

    • 这个页面是pfSense强制门户服务提供的模板,我只是修改了我关心的区域。我没有包含内联 CSS 代码。
    • @joebegborg07 只是我的建议,但如果您正在处理它,您不妨移动 css 并为图像和表格单元格提供 css 类。希望我的回答有帮助:)
    • 我刚刚解决了这个问题,并在稍后阶段应用您的建议。顺便说一句,我尝试将 display: inline 用于 MainTable 类,但这只会删除背景的颜色
    • 你添加了文档类型,这是最重要的部分。通常display: inline 用于 IE7/8
    • 是的,我有,但问题仍然存在。
    【解决方案3】:

    显然问题在于图像大小,它需要以像素而不是百分比为单位。

    【讨论】:

      猜你喜欢
      • 2011-02-09
      • 2013-07-22
      • 2012-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多