在段落中添加行号
Add line numbering in paragraphs
我正在开发一个 Web 应用程序,我必须在其中打印一个段落,每 5 行根据行号编号
I am living in New Jersey
2 who like to study music
create new applications
4 which can help others.
我无法为此编写 html/css 代码。
我正在使用 ajax 请求逐行提取段落数据并 Mustache.js 呈现数据
看看这个兄弟 http://jsfiddle.net/elviz/8necedtu/1/
p:nth-child(odd) span {
display:none;
}
这里我们需要更多的上下文。主要是您正在处理的 HTML 结构。
最重要的是,了解您的 <p>
标签和结构,行 returns 是如何完成的(<br/>
?)
可能很有趣
这个答案有点快速和肮脏,但有效。
好处是不需要为每一行添加一个 <p>
标签(因为这没有多大意义)。
不好的是它没有任何理由使用 <li>
标签,也没有使用 <ul>
父标签,除了通过 css
自动添加号码
所以请不要将此答案视为最终解决方案,而只是一个开始
HTML
<p>
<li>I am living in New Jersey</li><br/>
<li>who like to study music</li><br/>
<li>create new applications</li><br/>
<li>which can help others.</li><br/>
</p>
CSS
li:nth-of-type(even) {
list-style-type: decimal;
}
li:nth-of-type(odd) {
list-style-type: none;
padding-left: 1em;
}
我正在开发一个 Web 应用程序,我必须在其中打印一个段落,每 5 行根据行号编号
I am living in New Jersey
2 who like to study music
create new applications
4 which can help others.
我无法为此编写 html/css 代码。
我正在使用 ajax 请求逐行提取段落数据并 Mustache.js 呈现数据
看看这个兄弟 http://jsfiddle.net/elviz/8necedtu/1/
p:nth-child(odd) span {
display:none;
}
这里我们需要更多的上下文。主要是您正在处理的 HTML 结构。
最重要的是,了解您的 <p>
标签和结构,行 returns 是如何完成的(<br/>
?)
可能很有趣
这个答案有点快速和肮脏,但有效。
好处是不需要为每一行添加一个 <p>
标签(因为这没有多大意义)。
不好的是它没有任何理由使用 <li>
标签,也没有使用 <ul>
父标签,除了通过 css
所以请不要将此答案视为最终解决方案,而只是一个开始
HTML
<p>
<li>I am living in New Jersey</li><br/>
<li>who like to study music</li><br/>
<li>create new applications</li><br/>
<li>which can help others.</li><br/>
</p>
CSS
li:nth-of-type(even) {
list-style-type: decimal;
}
li:nth-of-type(odd) {
list-style-type: none;
padding-left: 1em;
}