2011-03-17 70 views
4

我有一些格式的文本:link to JSFiddle ,我想使它看起来像这样:CSS文字背景不同势文本行之间的空间

enter image description here

如何才能做到这一点?

+0

您与线之间的分离缘是什么意思?一个棘手的问题,除非我的大脑不工作(可能)。 +1 – Bojangles 2011-03-17 20:27:49

+0

JSFiddle链接是否正确?似乎很奇怪。 – Haza 2011-03-17 20:28:10

+0

JS小提琴是当我试图让设计师给我做的(图像) – 2011-03-17 20:29:47

回答

0

这..

.news_text{ 
 
    position:relative; 
 
    float:left; 
 
    font-family:Arial, Helvetica, sans-serif; 
 
    font-size:11px; 
 
    width:220px; 
 
    background-color:#866b62; 
 
    color:#FFF; 
 
    padding:3px; 
 

 
    line-height: 1.2em; /*notice line-height*/ 
 
    overflow: hidden; /*to hide extra transform*/ 
 
} 
 
.news_text::before{ 
 
background:repeating-linear-gradient(transparent,transparent calc(1.2em - 1px),white calc(1.2em - 1px),white calc(1.2em + 0px)); /*that same line-height*/ 
 
    background-repeat: repeat-y; 
 
content: ''; 
 
position:absolute; 
 
top:3px; /*same as padding*/ 
 
bottom: 1em; /*use with care when handling padding*/ 
 
left:0; 
 
right: 0; 
 
} 
 
.news_text::after{ 
 
content:'------'; /*'' blank was not working on inline-block*/ 
 
color:transparent; /*to hide '------'*/ 
 
background-color: white; /*same as background*/ 
 
position: relative; 
 
display: inline-block; 
 
transform-origin: top left; 
 
transform:scale(20,2) scaleY(1.1); /*adjust based on your content*/ 
 
}
<span id="news_text" class="news_text"> 
 
    Maecenas tempus rhoncus nisl, eu lorem blandit a consectetuer adipiscing 
 
    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Pariatur libero nobis, ut itaque, quibusdam, cumque corporis optio dignissimos consequatur voluptatum cum, provident officia 
 
</span>

不知道为什么我花了这么多时间....

相关问题