2016-12-05 89 views
6

我想在每个列表项后添加一个反斜杠,但我无法让它工作。它适用于如果我使用管道或正斜杠,但不反斜杠。我搜索了一个字符实体代码来使用,但我找不到一个反斜杠。有解决方案吗?如何在css内容属性中使用反斜线?

#navigation ul.nav > li:after{ 
    content: " \ "; 
} 

谢谢!

回答

7

使用双反斜线

#navigation ul.nav > li:after{ 
    content: '\\'; 
} 

要了解更多关于CSS转义序列检查this

使用双反斜线

span:after{ 
 
     content: '\\'; 
 
    }
<span></span>

\005C

使用\005C在内容@disinfor提到

span:after{ 
 
     content: '\005C'; 
 
    }
<span></span>

+0

工作。谢谢。只要它允许我会标记正确。 – LBF

+3

或者你可以使用这个:'\ 005C' – disinfor

+1

@disinfor ya true。谢谢,我已经更新了。感谢提及 – jafarbtech

0

嘿,我想花一个完整的例子

$dsp-md-imprint: "e900"; 

    @function unicode($str){ 
     @return unquote("\"")+unquote(str-insert($str, "\\", 1))+unquote("\"") 
    } 

    @mixin makeIcon($arg, $val , $os: null) { 
     // @debug $os; 
     // @debug $arg; 
     // @debug $val; 
     @if($os) { 
     .ion-#{$arg}:before, 
     .ion-#{$os}-#{$arg}:before , 
     .ion-#{$os}-#{$arg}-outline:before { 
      content: unicode($val); 
     } 
     } @else { 
     .ion-#{$arg}:before, 
     .ion-#{$arg}-outline:before, 
     .ion-md-#{$arg}:before, 
     .ion-md-#{$arg}-outline:before, 
     .ion-ios-#{$arg}:before, 
     .ion-ios-#{$arg}-outline:before { 
      content: unicode($val); 
     } 
     } 

} 

@include makeIcon(dsp-imprint, $dsp-md-imprint, md); 

和可测试here