在TailwindCSS的`content`属性中如何将某物添加为计数器后的点?

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

How does one add something as a dot after a counter inside a content property in TailwindCSS?

问题

  1. 我有这个编号列表(为了可读性,我省略了counter-reset和counter-increment):
<ol class="...">
    <li class="... before:content-[counter(name)]">我喜欢奶酪</li>
</ol>

这将产生:

1我喜欢奶酪

我想在计数器后面添加句点和空格,使其变成:

1. 我喜欢奶酪

但是框架不允许我解析通常在纯CSS中正常工作的内容:

content: counter(name) '.';

如何绕过这个问题,而不必手动添加硬编码的类?或者,是否有一种适当的方法来处理这个问题,通过创建一个特定的插件来接受类似的值?

编辑:我现在意识到确实存在list-decimal,它也可以做到这一点,但我特别想知道如果仍然在before中使用CSS计数器,是否有一个有效的替代方法?

英文:

I have this numbered list (I have omitted the counter-reset and counter-increment for legibility):

&lt;ol class=&quot;...&quot;&gt;
    &lt;li class=&quot;... before:content-[counter(name)]&quot;&gt;I like cheese&lt;/li&gt;
&lt;/ol&gt;

which results in

1I like cheese

I would like to add a period and a space after the counter, so it becomes:

1. I like cheese

but the framework won't let me parse something that normally would work in vanilla CSS:

content: counter(name) &#39;. &#39;;

How do I work around this without having to add a hard-coded class myself? Or perhaps, is there a proper way of handling this, by making a particular plugin that would accept a similar value?

Edit: I now realize there indeed is something as list-decimal which exactly does this too, but I am specifically curious about a working alternative if one would still use a CSS-counter in a before.

答案1

得分: 1

  1. 项目
  2. 项目
  3. 项目
  4. 项目

我认为这是你想要做的事情。

链接:https://flowbite.com/docs/typography/lists/

英文:
&lt;ol class=&quot;list-decimal list-inside&quot;&gt;
  &lt;li&gt;item&lt;/li&gt;
  &lt;li&gt;item&lt;/li&gt;
  &lt;li&gt;item&lt;/li&gt;
  &lt;li&gt;item&lt;/li&gt;
&lt;/ol&gt;

i think this is what you are trying to do.

https://flowbite.com/docs/typography/lists/

huangapple
  • 本文由 发表于 2023年8月10日 22:03:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76876476.html
匿名

发表评论

匿名网友

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

确定