Internet Explorer ol 数字显示在 li 的底部而不是预期的顶部

发布于 2024-07-04 22:05:48 字数 6661 浏览 8 评论 0原文

我正在处理的页面有一个带有嵌套 p、div 和 li 的 ol。 Internet Explorer 6 和 7 都在末尾的 p 元素之后(在 li 标记的最底部)呈现 ol 标记的数字,而不是按预期呈现在最外层 li 的顶部。 我正在 PowerPC Mac 上工作,无法进行任何测试。 是否有一些简单的 CSS hack 可以使此渲染与 Firefox 中的渲染相同?

您可以在此处查看实时页面。 我知道,我正在努力定位侧边栏。 暂时忽略它。

标记如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="stylesheet" type="text/css" href="css/global.css" />
        <link rel="stylesheet" type="text/css" href="css/whats_included.css" />
        <script type="text/javascript" src="script/compliant_target_blank.js"></script>
        <!--[if lte IE 5]>
            <script type="text/javascript" src="script/ie_5_unsupported_warning.js"></script>
        <![endif]-->
        <!--[if gt IE 5]>
            <link rel="stylesheet" type="text/css" href="css/ie_hacks/global.css" />
        <![endif]-->
        <title>
            The Daily Plan-It, LLC - Home of the Tax MiniMiser
        </title>
    </head>
    <body>
        <?php include("includes/nav_bar.php") ?>

        <div id="content">
            <img src="images/title.png" alt="Tax MiniMiser Financial Tracking System" />
            <div id="bordered_wrapper">
                <h1>Here's What You Get With The Tax MiniMiser!</h1>
                <h2>24 Envelopes, 7-hole punched to fit one-at-a-time in your binder</h2>
                <ol>
                    <li class="main_item">
                        Business Income &amp; Expense Record
                        <div class="preview_image">
                            <a href="previews/large/bier/front.html" rel="external">
                                <img src="images/small_previews/large/bier_preview.jpg" alt="" /><br/>
                                Click to Preview!
                            </a>
                        </div>
                        <div class="details">
                            <ul>
                                <li>12 receipt envelopes with all the income &amp; expense columns you need to transform your planner or binder into a daily tax journal!</li>
                                <li>Store daily receipts in the convenient pocket envelopes.</li>
                            </ul>
                        </div>
                        <p>To get a free copy of the &quot;20 Column Heading Guidelines&quot;, <a href="files/downloads/20_column_heading_guidelines.pdf">click here</a> or call our Fax-on-Demand line at 888-829-8237.</p>
                    </li>
                    <li class="main_item">
                        Vehicle Mileage &amp; Expense Record
                        <div class="preview_image">
                            <a href="previews/large/vme/front.html" rel="external">
                                <img src="images/small_previews/large/mileage_preview.jpg" alt=""/><br/>
                                Click to Preview!
                            </a>
                        </div>
                        <div class="details">
                            <ul>
                                <li>12 receipt envelopes to track your daily mileage and vehicle expenses. Keep one envelope in each vehicle used for your business(es).</li>
                                <li>Store daily receipts in the convenient pocket envelopes.</li>
                            </ul>
                        </div>
                        <p>To get a free copy of the &quot;Instructions for Vehicle Mileage &amp; Expense Record&quot;, <a href="files/downloads/vehicle_record_instructions.pdf">click here</a> or call our Fax-on-Demand line at 888-829-8237.</p>
                    </li>
                    <li class="main_item">
                        Annual Business Summary of Income and Expense
                        <div class="preview_image">
                            <a href="previews/large/cover/inside.html" rel="external">
                                <img src="images/small_previews/large/cover_inside_preview.jpg" alt="" /><br/>
                                Click to Preview!
                            </a>
                        </div>
                        <div class="details">
                            <ul>
                                <li>Enter the subtotals from all the envelopes throughout the year. Then you and your tax pro can figure out profitability and taxes to maximize your deductions and legally minimize your taxes.</li>
                            </ul>
                        </div>
                    </li>
                </ol>
                <p class="end">To see previews of the small (6&quot; x 8&frac12;&quot;) Tax MiniMisers, visit their respective pages <a href="products.php">here.</a></p>
            </div>
        </div>

        <?php include("includes/footer.php") ?>
    </body>
</html>

CSS:

#content {
    background-color: white;
}

#bordered_wrapper {
    margin-left: 26px;
    background: top left no-repeat url(../images/borders/yellow-box-top.gif);
}

#bordered_wrapper h1, #bordered_wrapper h2 {
    margin-left: 20px;
}

#bordered_wrapper h1 {
    padding-top: 15px;
    margin-bottom: 0;
}

#bordered_wrapper h2 {
    margin-top: 0;
    font-size: 1.3em;
}

ol {
    font-size: 1.1em;
}

ul {
    list-style-type: disc;
}

li.main_item {
    width: 700px;
    clear: right;
}

li p {
    clear: both;
    margin-bottom: 20px;
}

.preview_image {
    width: 200px;
    float: right;
    text-align: center;
    margin-bottom: 10px;
}

.preview_image a {
    text-decoration: none;
}

.preview_image img {
    border-style: none;
}

.end {
    clear: right;
    padding-bottom: 25px;
    padding-left: 20px;
    background: bottom left no-repeat url(../images/borders/yellow-box-bottom.gif);
}

I'm working on a page has an ol with nested p's, div's, and li's. Internet Explorer 6 and 7 both render the numbers for the ol tag after the p element at the end (at the very, very bottom of the li tag) rather than at the top of the outermost li as expected. I'm working on a PowerPC Mac and can't do any testing. Is there some simple CSS hack to make this render the same as it does in Firefox?

You can view the live page here. I know, I'm working on positioning the sidebar. Ignore that for now.

Markup is as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="stylesheet" type="text/css" href="css/global.css" />
        <link rel="stylesheet" type="text/css" href="css/whats_included.css" />
        <script type="text/javascript" src="script/compliant_target_blank.js"></script>
        <!--[if lte IE 5]>
            <script type="text/javascript" src="script/ie_5_unsupported_warning.js"></script>
        <![endif]-->
        <!--[if gt IE 5]>
            <link rel="stylesheet" type="text/css" href="css/ie_hacks/global.css" />
        <![endif]-->
        <title>
            The Daily Plan-It, LLC - Home of the Tax MiniMiser
        </title>
    </head>
    <body>
        <?php include("includes/nav_bar.php") ?>

        <div id="content">
            <img src="images/title.png" alt="Tax MiniMiser Financial Tracking System" />
            <div id="bordered_wrapper">
                <h1>Here's What You Get With The Tax MiniMiser!</h1>
                <h2>24 Envelopes, 7-hole punched to fit one-at-a-time in your binder</h2>
                <ol>
                    <li class="main_item">
                        Business Income & Expense Record
                        <div class="preview_image">
                            <a href="previews/large/bier/front.html" rel="external">
                                <img src="images/small_previews/large/bier_preview.jpg" alt="" /><br/>
                                Click to Preview!
                            </a>
                        </div>
                        <div class="details">
                            <ul>
                                <li>12 receipt envelopes with all the income & expense columns you need to transform your planner or binder into a daily tax journal!</li>
                                <li>Store daily receipts in the convenient pocket envelopes.</li>
                            </ul>
                        </div>
                        <p>To get a free copy of the "20 Column Heading Guidelines", <a href="files/downloads/20_column_heading_guidelines.pdf">click here</a> or call our Fax-on-Demand line at 888-829-8237.</p>
                    </li>
                    <li class="main_item">
                        Vehicle Mileage & Expense Record
                        <div class="preview_image">
                            <a href="previews/large/vme/front.html" rel="external">
                                <img src="images/small_previews/large/mileage_preview.jpg" alt=""/><br/>
                                Click to Preview!
                            </a>
                        </div>
                        <div class="details">
                            <ul>
                                <li>12 receipt envelopes to track your daily mileage and vehicle expenses. Keep one envelope in each vehicle used for your business(es).</li>
                                <li>Store daily receipts in the convenient pocket envelopes.</li>
                            </ul>
                        </div>
                        <p>To get a free copy of the "Instructions for Vehicle Mileage & Expense Record", <a href="files/downloads/vehicle_record_instructions.pdf">click here</a> or call our Fax-on-Demand line at 888-829-8237.</p>
                    </li>
                    <li class="main_item">
                        Annual Business Summary of Income and Expense
                        <div class="preview_image">
                            <a href="previews/large/cover/inside.html" rel="external">
                                <img src="images/small_previews/large/cover_inside_preview.jpg" alt="" /><br/>
                                Click to Preview!
                            </a>
                        </div>
                        <div class="details">
                            <ul>
                                <li>Enter the subtotals from all the envelopes throughout the year. Then you and your tax pro can figure out profitability and taxes to maximize your deductions and legally minimize your taxes.</li>
                            </ul>
                        </div>
                    </li>
                </ol>
                <p class="end">To see previews of the small (6" x 8½") Tax MiniMisers, visit their respective pages <a href="products.php">here.</a></p>
            </div>
        </div>

        <?php include("includes/footer.php") ?>
    </body>
</html>

And the CSS:

#content {
    background-color: white;
}

#bordered_wrapper {
    margin-left: 26px;
    background: top left no-repeat url(../images/borders/yellow-box-top.gif);
}

#bordered_wrapper h1, #bordered_wrapper h2 {
    margin-left: 20px;
}

#bordered_wrapper h1 {
    padding-top: 15px;
    margin-bottom: 0;
}

#bordered_wrapper h2 {
    margin-top: 0;
    font-size: 1.3em;
}

ol {
    font-size: 1.1em;
}

ul {
    list-style-type: disc;
}

li.main_item {
    width: 700px;
    clear: right;
}

li p {
    clear: both;
    margin-bottom: 20px;
}

.preview_image {
    width: 200px;
    float: right;
    text-align: center;
    margin-bottom: 10px;
}

.preview_image a {
    text-decoration: none;
}

.preview_image img {
    border-style: none;
}

.end {
    clear: right;
    padding-bottom: 25px;
    padding-left: 20px;
    background: bottom left no-repeat url(../images/borders/yellow-box-bottom.gif);
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

陪我终i 2024-07-11 22:05:48

我刚刚在 firefox 3/webkit nightly/internet explorer 7 中测试了您的示例 html,所有这些都与顶部应有的数字完全相同。

问题可能出在您的 CSS 中,您能否向我们展示损坏的实际页面?

I just tested your example html in firefox 3/webkit nightly/internet explorer 7 and all of them rendered exactly the same with the number at the top where it should be.

The problem is probably in your CSS, can you show us the actual page that is broken?

酷到爆炸 2024-07-11 22:05:48

同样的情况,在WinXP Pro SP3上用IE6测试,显示正确。 您应该提供重现问题的代码片段或实时网页。 也许环境很重要,或者现有的 CSS 等。

Same here, tested with IE6 on WinXP Pro SP3, it shows correctly. You should provide a snippet reproducing the problem, or a live Web page. Perhaps the environment counts, or the existing CSS, etc.

掩耳倾听 2024-07-11 22:05:48

其实我也遇到过这个bug。 在我的页面中,只有在使用 javascript 更改编号后才会发生这种情况。 唯一可用的真正解决方案是使用:

vertical-align: top;

老实说,我不知道 IE7 为何这样做,但是有一种简单的方法可以修复它。

Actually, I ran into this bug as well. With my page it only happened after changing the numbering using javascript. The only somewhat real solution available is using:

vertical-align: top;

I honestly have no idea why IE7 is doing, however there is an easy way to fix it.

马蹄踏│碎落叶 2024-07-11 22:05:48

恭喜,您已成为 IE hasLayout 属性的受害者。

简短版本:这次你很容易了。 更改这些规则:

...

ol {
    font-size: 1.1em;
}

...

li.main_item {
    width: 700px;
    clear: right;
}

...

对此:

...

ol {
    font-size: 1.1em;
    width: 700px;
}

...

li.main_item {
    clear: right;
}

...

一切都很好。

更长的版本:当您将某些 CSS 规则应用于某些元素时,IE 5.5+ 会为这些元素提供一个名为“hasLayout”的属性,该属性会更改该元素的呈现方式。 由于 hasLayout 是一个没有明显用途的只读属性,因此网页设计人员花了很长时间才意识到这个问题。 较旧的网站(甚至 Quirksmode.org!)仍然有一些页面建议调整填充、边距,甚至使用 Javascript 来解决这些问题。 如果你能帮得上忙,就不要做这些事情。 相反,看看是否可以找出哪个元素被错误地赋予了 hasLayout,并更改有问题的 CSS,以便该元素不再获得 hasLayout。 如果这完全破坏了您的页面,请使用 条件注释 来修复它(仅适用于 IE)。 以下是一些 CSS 规则,可将“hasLayout”添加到尚未包含它的元素:

  • position:absolute
  • float:left|rightdisplay
  • :inline-block
  • height:any value other than 'auto'zoom
  • :any value other than '正常'(MS专有)
  • 写入模式:tb-rl(MS专有)

从IE7开始,溢出成为hasLayout的触发器。

  • 溢出:hidden|scroll|auto

最长版本:阅读以下文章。

  1. 以下是 Microsoft 希望您通过触发“hasLayout”执行的所有巧妙操作。
  2. 这是网页设计师在发现发生的情况后对 hasLayout 的看法的简洁语言版本。 一些内容相同,但包括 CSS hack 之类的东西。

Congratulations, you are the victim of IE's hasLayout property.

Short version: You've got it easy this time. Changes these rules:

...

ol {
    font-size: 1.1em;
}

...

li.main_item {
    width: 700px;
    clear: right;
}

...

To this:

...

ol {
    font-size: 1.1em;
    width: 700px;
}

...

li.main_item {
    clear: right;
}

...

And it's all good.

Longer version: When you apply certain CSS rules to certain elements, IE 5.5+ gives those elements a property called "hasLayout" that changes how that element is rendered. Since hasLayout was a read-only property with no apparent purpose, it took quite a while before web designers caught on to the issue. Older sites (even Quirksmode.org!) still has pages that suggest twiddling padding, margins, or even using Javascript to fix these issues. If you can at all help it, don't do these things. Instead, see if you can find out what element is incorrectly being given hasLayout, and change the offending CSS so that the element no longer gets hasLayout. If that totally borks your page, use conditional comments to fix it just for IE. Here are some CSS rules that add "hasLayout" to an element that doesn't already have it:

  • position: absolute
  • float: left|right
  • display: inline-block
  • height: any value other than 'auto'
  • zoom: any value other than 'normal' (MS proprietary)
  • writing-mode: tb-rl (MS proprietary)

As of IE7, overflow became a trigger for hasLayout.

  • overflow: hidden|scroll|auto

Longest version: read the following articles.

  1. Here's all the neat things Microsoft would like you do by triggering "hasLayout".
  2. Here's the clean-language version of what web designers thought about hasLayout when they found out what was going on. Some of the same content, but includes CSS hacks and stuff.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文