2010-07-19 55 views
0

我正在編寫一些CSS來自定義XML文檔的顯示。基本上我想定製子元素的顯示,並將它們渲染爲與HTML OL/UL/LI元素類似。列表中的xml計數元素在Firefox中不起作用

我的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等工作。

任何可以提供一個鏈接或sultion,可以在Firefox以及其他瀏覽器?

回答

1

它看起來像firefox實現display:list-item屬性,特別是計數器值的傳遞方式有一些錯誤。我相信這會產生在Firefox中顯示的零,但不在鉻中。

我的解決辦法是忘記使用「顯示:列表項」,而是直接樣式的項目,使他們出現作爲列表:

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> 

讓我知道你上車......

AL