2016-01-18 87 views
2

我使用此代码在菜单项之间添加分隔符。在新行上删除分隔符(“:before”)

li:before { 
    content: '\00B7'; 
    float: left; 
} 

有什么办法可以删除分隔符,如果我去一个新的行? 见图片(我想之前 “测试类别2” 中删除点)

这是我有:

enter image description here

这就是我想做的事:

enter image description here

+2

我不认为有可能提供一个明确的解决方案,而没有看到你的HTML。 – nicael

+1

http://stackoverflow.com/questions/783899/how-can-i-count-text-lines-inside-an-dom-element-can-i是你需要和动态的CSS结合起来! –

+3

基本上没有。 CSS无法检测元素内容将包裹的位置。您需要JS ....或一组合理的媒体查询。 –

回答

0

你可以结合CSS伪类如:nth-child:last-child做类似的事情:

li:last-child:before { 
    content: ''; 
    float: left; 
} 

,或者如果它的倒数第三

li:nth-last-child(3):before { 
    content: ''; 
    float: left; 
} 

然后,你也许可以用媒体查询相结合这一点。