P粉9365096352023-08-25 19:18:50
You should change the display attribute of .header-text to block or inline-block
P粉6148403632023-08-25 12:32:44
What you want can be achieved by using box-decoration-break
, and it even works with 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'> 长文本换行 </span> </h1> </div>