如何在CSS中的多行段落中添加背景颜色?

时间:2018-04-18 15:17:49

标签: html css

所以这就是概念:

enter image description here

这里是基本样本I made this on codepen,但是每一行都缺少填充。



.wrapper {
  margin: 1em;
  max-width: 500px;
}

p {
  color: white;
  font-size: 24px;
  
  /* Main Style for the paragraph effect */
  display: inline;
  background: #191c34;
  padding: 4px;
  line-height: 1.8;
}

<div class="wrapper">
  <p>
    The latest console of the world renown nintendo company which produced some of the most loved games of your childhood and the children today.
  </p>
</div>
&#13;
&#13;
&#13;

我记得有一个使用文字阴影/盒子阴影的解决方案吗?

1 个答案:

答案 0 :(得分:1)

解决方案在这里:http://jsfiddle.net/cLh0onv3/451/

只需添加box-decoration-break: clone;和一个box-shadow即可在每行的末尾显示伪填充:box-shadow: 0.250em 0 0 $black,-0.250em 0 0 $black;