ordered list does not work on IE7 (
    <li)

2019-06-22 04:45发布

I am trying to create an ordered list on IE7 but for some reason does not work. Does anybody knows why this can be? Update

The issue is that I cant see the numbers, thanks.

Thanks.

eg.

<ol>
 <li></li>
 <li><li>
</ol>

Update As an example I saw this page where if you look at it on IE7 you wont see de numbers, but if you look at it on any other (but not ie) you will see the numbers.

http://www.arraystudio.com/as-workshop/make-ol-list-start-from-number-different-than-1-using-css.html

Thanks

7条回答
Summer. ? 凉城
2楼-- · 2019-06-22 05:05

If you're not seeing the numbers at all, it's likely you need to set a margin or padding on the ol element, e.g.

ol {
    margin-left: 3em;
}

You might also need to set list-style: decimal;.

There's also some CSS bugs that can have a weird effect on ordered lists in older versions of IE. The symptom is usually the counter resetting to 1 for every item. Are you seeing that?

查看更多
混吃等死
3楼-- · 2019-06-22 05:06

I also stumbled upon this old question. For me the solution was to remove the float:left declaration I had on my ol-tag. Posting it here in case someone finds it useful.

Example code that reproduces this IE7-behavior:

<!doctype html>
<html lang="en">
    <head>
        <title>SO question 2401705 - IE6/7 problem</title>
    <style type="text/css">ol { float:left; }</style>
</head>
<body>
    <ol>
        <li>Item 1</li>
        <li>Item 2</li>
    </ol>
</body>

查看更多
Explosion°爆炸
4楼-- · 2019-06-22 05:09

This question is old, but I felt none of the answers solved my case:

ol {list-style-position:inside;}
li {display:list-item;}

<ol>
   <li>foo</li>
   <li>bar</li>
</ol>
  • list-style-position: inside 
    

    Fixes the list so that the numbers appear (don't use margin)

  • display:list-item
    

    When list elements have either a width, or layout (? I forget), IE7 has a numbering bug and all list elements show as 1.; this fixes that.

查看更多
淡お忘
5楼-- · 2019-06-22 05:11

This SSCCE works fine in all browsers from IE6 and up (IE6/7/8, FF2/3, Safari3, Chrome4, Opera9).

<!doctype html>
<html lang="en">
    <head>
        <title>SO question 2401705</title>
    </head>
    <body>
        <ol>
            <li>Item 1
            <li>Item 2
        </ol>
    </body>
</html>

It even works when I tried to replace the </ol> by the syntactically invalid <ol>. So, your problem lies somewhere else. You really need to elaborate the "Doesn't work" in more detail. What exactly happens? What exactly happens not? Preferably edit your question to include an SSCCE (like above) and try to ask the question the smart way.

Note, in contrary to what others say, a non-closing <li> is syntactically valid in normal HTML. It's indeed invalid in XHTML, but I don't see any reason to use XHTML unless you're using a component based MVC framework or some other XML based tool to generate HTML pages.

Update: you thus don't see the numbers. Apparently you've set the margin of the ol to zero. This way they will get out of the view. The following SSCCE demonstrates it. It indeed fails in IE6/7.

<!doctype html>
<html lang="en">
    <head>
        <title>SO question 2401705 - IE6/7 problem</title>
        <style>ol { margin: 0; }</style>
    </head>
    <body>
        <ol>
            <li>Item 1
            <li>Item 2
        </ol>
    </body>
</html>

Don't set the margin to 0. This may also be caused by a so-called CSS reset sheet. Don't use them, just remember to specify the margins for all block elements yourself.

查看更多
Ridiculous、
6楼-- · 2019-06-22 05:13

Complete your tags and it should be fine:

<ol>
 <li>blah</li>
 <li>ha</li>
</ol>
查看更多
萌系小妹纸
7楼-- · 2019-06-22 05:15

You may also have to give your ordered list a margin-left to see the numbers in IE7. Try this:

<ol style="margin-left:25px;"> 
 <li>test1</li> 
 <li>test2</li> 
</ol>
查看更多
登录 后发表回答