代码之家  ›  专栏  ›  技术社区  ›  Dai Bok

在firefox中,对列表中的元素进行xml计数不起作用

  •  0
  • Dai Bok  · 技术社区  · 16 年前

    我的XML结构如下:

     <?xml version="1.0"?>
     <?xml-stylesheet type="text/css" href="style.css"?>
     <transcription>
          <turn>
              <speaker>Speaker Name</speaker>
              <clause>
                  text here
              </clause>
              <clause>
                  one or  more clauses
              </clause>
          </turn>
      </transcription>
    

    我的CSS如下所示:

    turn {
        counter-reset: item;
    }
    
    turn clause {
        display:list-item;
    }
    
    clause  {
        content: counter(item);
        counter-increment: item;
    }
    

    http://www.xml.com/lpt/a/401 基本上有一个类似的文件 http://www.xml.com/2000/03/29/tutorial/examples/display1.xml ,问题是display1.xml在firefox中不起作用。我在IE、Safari、Chrome等方面都能用。

    任何一个浏览器都能提供一个链接,或者一个可以在firefox和其他浏览器中使用的sultion吗?

    1 回复  |  直到 14 年前
        1
  •  1
  •   AnotherLongUsername    16 年前

    看起来firefox实现display:list item属性的方式中有一些bug,特别是计数器值的传递。我相信这会导致firefox中出现0,但chrome中没有。

    我的解决方法是忘记使用“display:list item”,而是直接设置项的样式,以便它们 出现 作为列表:

    transcription {
          counter-reset: item;
    }
    
    clause {
          display:block; 
          margin-left:40px; 
    }
    
    clause:before  {
          counter-increment: item;
          content: counter(item)  ". ";
    }
    

    这适用于以下XML:

    <?xml version="1.0"?>
    <?xml-stylesheet type="text/css" href="style2.css"?>
    <transcription>
        <turn>
        <speaker>Speaker Name</speaker>
        <clause>
            text here
        </clause>
        <clause>
            text here
        </clause>
        <clause>
            text here
        </clause>
    </turn>
    

    铝

    推荐文章