CSS,在文本旁边创建一行

CSS, create a line next to text

我已经阅读了多个线程但没有成功。

我正在寻求帮助,以便在 CSS 中的文本旁边创建一行。我不允许更改 HTML 代码,因此将 span 元素添加到 html 代码对我来说不是解决方案。

这是它的样子。

<legend>Text</legend>

我想创建这样的一行http://imgur.com/BVQ2txt

在不更改 html 代码的情况下有什么解决方案吗?

你可以这样做:

legend { height: 18px; position: relative; background: #fff; display: inline-bock; margin-left: 5px; } 
legend:before { content: ""; display: block; font-size: 0; line-height: 0; text-indent: -4000px; position: absolute; top: 8px; left: -5px; right: -100px; height: 1px; border-top: 1px solid red; z-index: -1; }