简体   繁体   English

使用css行编号的段落

[英]line numbered paragraph using css

I have a bad habit of writing overly long paragraphs that go on and on. 我有一个坏习惯,那就是写长篇幅不停的段落。 As a way of helping myself visually scan my document and find some paragraphs that desperately need to be broken up, I'd like some way to have line numbers next to my paragraphs. 作为一种帮助自己直观地扫描文档并找到急需分解的段落的方法,我想以某种方式在段落旁边添加行号。 Pure CSS would be neat, but since this is just for me, JS is also fine. 纯CSS会很整洁,但是由于这只适合我,JS也很好。 Wrapping each line in its own tag is not an option: this is a document in flux. 将每行包装在自己的标签中不是一种选择:这是一个不断变化的文档。 Bonus points: number every 5th line or something. 加分:每第5行编号。 Hopefully my phrasing is clear; 希望我的表述是明确的; if not I can clarify. 如果没有,我可以澄清。

(On an unrelated note: any opinions on how long a paragraph can get before it's too long?) (不相关的注释:对于段落过长可以得到多长时间有任何意见吗?)

EDIT: Okay, based on the comment and the answer I've gotten so far, it seems I was hopelessly unclear. 编辑:好的,根据到目前为止的评论和回答,似乎我并不确定。 Let's try again. 让我们再试一次。 Suppose I have two paragraphs. 假设我有两段。 Paragraph one is ten lines long, in the current font, browser width, etc. Paragraph two is very short, just 3 lines long. 第一段长十行,以当前字体,浏览器宽度等表示。第二段很短,只有三行。 Then I want the numbers 1 through 10 next to the first paragraph, and the number 1 through 3 next to the second paragraph. 然后我要在第一段旁边输入数字1至10,在第二段旁边输入数字1至3。 Make sense? 说得通?

Not sure what exactly you are looking for 不确定您到底在寻找什么

If you are looking to number p tags with css,you can do it using css-counters 如果要使用CSS为p标签编号,则可以使用css-counters

check this snippet 检查此片段

 .container { counter-reset: pcount; } p::before { content: counter(pcount) "):"; counter-increment: pcount; } 
 <div class="container"> <p>This is p</p> <p>This is p</p> <p>This is p</p> <p>This is p >This is p >This is p >This is p >This is p >This is p >This is p >This is p >This is p</p> <p>This is p</p> </div> 

Hope this helps 希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM