gpt4 book ai didi

html - 如何对多行文本中的每一行应用填充?

转载 作者:技术小花猫 更新时间:2023-10-29 11:42:59 27 4
gpt4 key购买 nike

我已将背景颜色应用于 <span>标签,还有左右padding放在上面。问题是:padding仅应用于 <span> 的左侧(开始)和右侧(结束) ,而不是当文本换行在多行时每行的左侧(开始)和右侧(结束)。

如何应用左右padding中间线?

h1 {
font-weight: 800;
font-size: 5em;
line-height: 1.35em;
margin-bottom: 40px;
color: #fff;
}
h1 span {
background-color: rgba(0, 0, 0, 0.5);
padding: 0 20px;
}
<h1><span>The quick brown fox jumps over the lazy dog.</span></h1>

最佳答案

您可以使用值为 clonebox-decoration-break 属性。

box-decoration-break: clone; Each box fragment is rendered independently with the specified border, padding and margin wrapping each fragment. The border-radius, border-image and box-shadow, are applied to each fragment independently. The background is drawn independently in each fragment which means that a background image with background-repeat: no-repeat may be repeated multiple times. - MDN

caniuse.com 查看当前浏览器支持表

jsFiddle example

h1 {
font-weight: 800;
font-size: 5em;
line-height: 1.35em;
margin-bottom: 40px;
color: #fff;
}
h1 span {
background-color: rgba(0, 0, 0, 0.5);
padding: 0 20px;
-webkit-box-decoration-break: clone;
box-decoration-break: clone;
}
<h1><span>The quick brown fox jumps over the lazy dog.</span></h1>

关于html - 如何对多行文本中的每一行应用填充?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34659853/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com