There is some text whose formatting I would like to render in HTML. Here is an image:
Note the gray lines with the bullet points and the paragraph numbers. The bullets should be centered on the page and the numbers should be justified right.
I've been trying to think of how to do this in HTML and am coming up blank. How would you capture this formatting?
There are several ways I can think of:
If the total width of the area is, say, 300px
Many people prefer using pure CSS, but I like my tables, they just work for me
I would float the number right and center the remaining contents (the bullet points). If you give the remaining contents an equal left and right margin larger than the numbers are wide, the contents will be centered.
How about something like this?
http://jsfiddle.net/6eTCf/
You can use the
:before
and:after
psuedo-elements to great effect here:http://jsfiddle.net/yNnv4/1/
This will work in all modern browsers and IE8+. If IE7 support is required, this answer is not for you :)
About the
counter
properties:It's not possible to (automatically) increment the bullets.
However, it can be done with some dubious repetition:
http://jsfiddle.net/N4txk/1/
(alternatively,
:nth-child
can be repeated in the same way: http://jsfiddle.net/N4txk/ - but it won't work in IE8; there will only be two bullets)There is an upper limit on the number of bullets it would be sensible to have, so I think it would be acceptable to copy and paste that as many times as required.
I would wrap the whole thing in a div, then use relative/absolute positioning between the wrapper and the paragraph number div to get the numbers on the right-hand side like that.
Here's a fiddle showing how to do it.
There are a couple ways I can think of.
Add a
<div>
between the paragraphs, then add two<p>
's:<p class="dot"></p>
and<p class="pnum">1</p>
.Style the
<div>
to the width of the the paragraphs, and set in the CSS the following: