CSS: How to center text with surrounding borders

后端 未结 1 743
逝去的感伤
逝去的感伤 2021-01-16 10:49

I am trying to center text that has a line going through the entire background. On either side of the text, there is some padding, where you cannot see the line at all. I am

1条回答
  •  不知归路
    2021-01-16 11:20

    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/

    
        

    Latest Track

    ​ .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.​

    0 讨论(0)
提交回复
热议问题