文本背后的行可以仅用CSS完成吗?
是.
HTML:
Centered Header Text
CSS:
body { background: #ccc; } h2 { text-align: center; display: table; width: 100%; } h2 > span, h2:before, h2:after { display: table-cell; } h2:before, h2:after { background: url(http://dummyimage.com/2x1/f0f/fff&text=+) repeat-x center; width: 50%; content: ' '; } h2 > span { white-space: nowrap; padding: 0 9px; }
的jsfiddle
资源