你應(yīng)該將.header-text的display屬性改為block或inline-block
你想要的可以透過(guò)使用box-decoration-break
來(lái)實(shí)現(xiàn),而且它甚至可以與border-radius
一起使用:
.wrapper { width: 200px; } h1 { font-size: 32px; font-family: Tahoma, Helvetica, sans-serif; line-height: 50px; } .header-text { background: #aabbcc; padding-left: 20px; padding-right: 20px; border-radius: 6px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
<div class='wrapper'> <h1> <span class='header-text'> 長(zhǎng)文本換行 </span> </h1> </div>