我有一小段文字,我需要给各个行加上背景颜色,中间要留空格。

我已经部分实现了

<div class="styleText">
    <span class="spaced">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</span>
</div>




.styleText .spaced{
    background: rgba(0,0,0,6.5);
    line-height: 1.2em;
    /*width: 421px;*/
}


但是,我需要所有的线都具有相同的宽度,并且希望在每条线的开始和结束以及顶部和底部填充。

谁能想到实现此效果的方法,还是我对styleText类使用一些背景图像技巧的唯一选择?

最佳答案

我使用背景图片达到了效果:

.styleText{width: 387px; position: absolute; right: 0; bottom: 0; background: url(../images/styledTextBG.png) 0 2px; padding: 0 17px}
.styleText .spaced{line-height: 35px; display: inline; min-width: 421px;}


外观如下:



(天哪,我仍然需要设置文字样式)

10-07 14:28