为什么 Edge 和 Firefox 中的
标签编号结果不同?

huangapple go评论58阅读模式
英文:

Why are there two different results for the numbering of <dl> tags in Edge and Firefox?

问题

The following snippets produce different results in Edge and Firefox:

dd {
  display: list-item;
  list-style-position: inside;
  list-style-type: decimal;
  counter-increment: 1;
}
<ul>
  <li>A</li>
  <li>B</li>
  <li>C</li>
</ul>
<dl>
  <dt>Title</dt>
  <dd>One</dd>
  <dd>Two</dd>
  <dd>Three</dd>
</dl>

In Edge, the <dl> list correctly starts with index 1. On the other hand, in Firefox, it starts from 4.

After I deleted the <ul> node above the <dl> tag, the numbering of the <dd> tags started from 1 in Firefox. I don't know why this happened.

I want the <dd> tags to start from position 1 in Firefox. What should I do?

英文:

The following snippets produce different results in Edge and Firefox:

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

dd {
  display: list-item;
  list-style-position: inside;
  list-style-type: decimal;
  counter-increment: 1;
}

<!-- language: lang-html -->

&lt;ul&gt;
  &lt;li&gt;A&lt;/li&gt;
  &lt;li&gt;B&lt;/li&gt;
  &lt;li&gt;C&lt;/li&gt;
&lt;/ul&gt;
&lt;dl&gt;
  &lt;dt&gt;Title&lt;/dt&gt;
  &lt;dd&gt;One&lt;/dd&gt;
  &lt;dd&gt;Two&lt;/dd&gt;
  &lt;dd&gt;Three&lt;/dd&gt;
&lt;/dl&gt;

<!-- end snippet -->

In Edge, the &lt;dl&gt; list correctly starts with index 1. On the other hand, that of Firefox is 4.

After I deleted the &lt;ul&gt; node above the &lt;dl&gt; tag, the numbering of the &lt;dd&gt; tags started from 1. I don't know why this happened.

I want the &lt;dd&gt; tags to start from position 1 in Firefox. What should I do?

答案1

得分: 1

"Looks like Firefox is using the same counter for LI in UL, and DD in DL - but doesn't reset it on the DL element level.

Try adding dl { counter-reset: list-item; }"

英文:

Looks like Firefox is using the same counter for LI in UL, and DD in DL - but doesn't reset it on the DL element level.

Try adding dl { counter-reset: list-item; }

huangapple
  • 本文由 发表于 2023年5月22日 16:04:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/76304139.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定