CSS: How to center text with surrounding borders

放肆的年华 提交于 2019-12-01 13:18:52

Here you go. Had to add a wrapping span (necessary so we can set the background to white so the line doesn't hit the text)

http://jsfiddle.net/gtspk/9/

<span class="line">
    <h2><span>Latest Track</span></h2>
</span>​

.line{display:block; margin:25px}
.line h2{font-size:15px; text-align:center; border-bottom:1px solid red; position:relative; }
.line h2 span { background-color: white; position: relative; top: 10px; padding: 0 10px;}

Right, sorry, misunderstood what you meant by padding. Fixed.​

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