2017-02-08 6 views
0

私は複数行切り捨てのsass mixinを使用しています。それはクロムに '...'を表示しません。デバッグ中に私は-webkit-box-orientを得ました:垂直;適用されません。以下は複数行切り捨てでChromeで '...'が表示されない

コードです:あなたはこの記事で解決策を見つけることができますヘルプ

答えて

0

を事前に

overflow: hidden; 
    max-height: $font-size*$line-height*$lines-to-show; /* Fallback for non-webkit */ 

    display: -webkit-box; 
    -webkit-line-clamp: $lines-to-show; 
    -webkit-box-orient: vertical; 

    // Solution for Opera 
    text-overflow: -o-ellipsis-lastline; 

    font-size: $font-size; 
    line-height: $line-height; 
    text-overflow: ellipsis; 

ありがとう:

http://hackingui.com/front-end/a-pure-css-solution-for-multiline-text-truncation/

@mixin multiLineEllipsis($lineHeight: 1.2em, $lineCount: 1, $bgColor: white){ 
    overflow: hidden; 
    position: relative; 
    line-height: $lineHeight; 
    max-height: $lineHeight * $lineCount; 
    text-align: justify; 
    margin-right: -1em; 
    padding-right: 1em; 
    &:before { 
    content: '...'; 
    position: absolute; 
    right: 0; 
    bottom: 0; 
    } 
    &:after { 
    content: ''; 
    position: absolute; 
    right: 0; 
    width: 1em; 
    height: 1em; 
    margin-top: 0.2em; 
    background: $bgColor; 
    } 
} 

サンプルがありますあなたが結果を見ることができるcodepenで:

http://codepen.io/natonischuk/pen/QbGWBa

+0

これは問題なく動作します。テキストを正当化したくない場合は、空のスペースが作成されます。 3行目に表示される最後の単語に固執する方法はありますか?(linecount- let 3) – mahil

+0

ブロック内の最新の見える単語を検出するためにjavascriptを実行する必要があると思います。私はこれが現時点ではcssでは可能ではないと思います。 –

関連する問題