Reputation: 16089
I would like to use CSS to change the appearance of the <hr>
elements on a page: instead of a horizontal line, I'd like each one to appear as a set of three asterisks. I can accomplish that using something like this:
hr {
border: none;
margin: 3.0rem auto;
width: 5rem;
}
hr:before {
content: "***";
letter-spacing: 1rem;
}
(Fiddle here.)
The problem is getting this generated content to appear horizontally centered. I can get it more-or-less centered by tweaking the "width" property of the <hr>
, but this feels hacky and inflexible. Is there a way to tell the browser that this content should be centered?
Upvotes: 1
Views: 107
Reputation: 207861
Remove the width property and add text-align:center;
to the hr rule:
hr {
border: none;
margin: 2.0rem auto;
text-align:center;
}
Upvotes: 3
Reputation: 24302
How about this,
hr {
border: none;
margin: 2.0rem auto;
text-align:center;
}
hr:before {
content: "***";
letter-spacing: 1rem;
}
Upvotes: 3