gpt4 book ai didi

css - 使用显示 :inline-block 渲染行与行之间有白色间隙的多行文本组件

转载 作者:行者123 更新时间:2023-12-05 03:19:22 25 4
gpt4 key购买 nike

如何呈现行间有白色间隙的多行文本组件?该组件必须使用 display: inline-block .

我有一个 <code>带有多行文本的标记。我被告知不要更改内容或 display属性,但以某种方式在行之间制造间隙,以便 background-color属性只影响一行。 display: inline-block 甚至有可能吗? ?

我找到了另一个 similar question , 但那里的例子适用于 display: inline .

这是我想要得到的:

code {
background-color: aqua;
line-height: 1.5;
}
<code>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humor and the like).</code>

最佳答案

您可以考虑结合inline-block

的渐变着色

code {
display: inline-block;
background: linear-gradient(0deg,#0000 5px,aqua 0) 0 2px/100% 1.5em;
line-height: 1.5;
}
<code>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humor and the like).</code>

关于css - 使用显示 :inline-block 渲染行与行之间有白色间隙的多行文本组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73472663/

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