How to place a css counter-increment below a paragraph of text?

淺唱寂寞╮ 提交于 2020-01-05 03:54:11

问题


The attached fiddle places a counter-increment next to each paragraph.

Is it possible, within each paragraph of text, <p>, to include the counter-increment element below each paragraph, aligned on the right side?

I have also created a Fiddle

If an updated fiddle could please be provided, it would be extremely helpful, as I am still new to coding.


HTML:

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vel enim vitae dolor luctus gravida. Vestibulum elementum eget augue eu imperdiet. Vestibulum rhoncus nibh eget lorem sodales auctor. Maecenas egestas volutpat condimentum. Mauris et lacinia nisl, a condimentum neque. Nunc euismod arcu volutpat odio auctor rhoncus vel sit amet lorem. Donec consectetur lacus arcu, vel dictum nisi consectetur sit amet. Vivamus vel nisl vel metus maximus pulvinar. Suspendisse non lacinia massa, at condimentum justo. Suspendisse potenti. Curabitur enim leo, venenatis nec quam id, elementum lacinia sem. Aenean velit dui, viverra ac placerat tempus, pharetra a est.</p>


<br></br>


<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vel enim vitae dolor luctus gravida. Vestibulum elementum eget augue eu imperdiet. Vestibulum rhoncus nibh eget lorem sodales auctor. Maecenas egestas volutpat condimentum. Mauris et lacinia nisl, a condimentum neque. Nunc euismod arcu volutpat odio auctor rhoncus vel sit amet lorem. Donec consectetur lacus arcu, vel dictum nisi consectetur sit amet. Vivamus vel nisl vel metus maximus pulvinar. Suspendisse non lacinia massa, at condimentum justo. Suspendisse potenti. Curabitur enim leo, venenatis nec quam id, elementum lacinia sem. Aenean velit dui, viverra ac placerat tempus, pharetra a est.</p>

CSS:

body {
counter-reset: section;}

p:before {
counter-increment: section;
content: "Section " counter(section) ". ";}

回答1:


change p.before as below:

p:after {
    display: block;
    text-align: right;
    counter-increment: section;
    content: "Section " counter(section) ". ";
}

fiddle : https://jsfiddle.net/roullie666/10e4t9b4/3/



来源:https://stackoverflow.com/questions/33684549/how-to-place-a-css-counter-increment-below-a-paragraph-of-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!