2016-10-07 6 views
0

<p>タグ内のwhite-space: nowrap;がCSSでスパンの先頭に改行を挿入しないようにするにはどうすればよいですか?レンダリングされたドキュメントにCSSの空白が改行されないようにするにはどうすればよいですか?

私はこれを行うには、行の高さの計算を使用するソリューションについて読んだ

など、検索結果の抜粋の最後の行に楕円を入れて、それをデスクトップ上に見栄え持って、携帯したいのですが、それは壊れやすく、おそらくハッキリと思われる。

私は2つの領域のコンテンツを作成し、text-overflow: ellipsis;を2番目のものに入れたいと思っています。私が望む効果を得ることができます。

私が問題になるのは、white-space: nowrap;をスパンの先頭に改行したときです。 !ここで問題in a fiddle

を置くための@DaniPへ:(

Hatの先端には、私の検索結果テンプレートです:ここで

<a href="/some-url/" class="search-result"> 
    <div class="well"> 
     <h4>title</h4> 
     <p>See All Selfies Taken with iPhone Camera 
Ready to see every selfie taken with the iPhone camera on a device? Here’s all you need to do: 
1 Open the Pho<span>tos app as usual but tap on the “Albums” button 
2 From the “Albums” view (tap back to Albums if you’re in Camera Roll), scroll down to find the “Sel</span></p> 
    </div> 
</a> 

はSASS

.search-result {  
    p { 
     overflow: hidden; 
     text-overflow: ellipsis; 
     span { 
      white-space: nowrap; 
     }  
    } 
} 

であり、ここで何です次のようになります。

title 
See All Selfies Taken with iPhone Camera Ready to see every selfie taken with the iPhone camera on a device? Here’s all you need to do: 1 Open the Ph 
tos app as usual but tap on the “Albums” button 2 From the “Albums” view (tap back to Albums if you’re in Camera Roll), scroll down to find the “Sel 
ここ

は、私はそれはそれは改行を入れていない

title 
See All Selfies Taken with iPhone Camera Ready to see every selfie taken with the iPhone camera on a device? Here’s all you need to do: 1 Open the Photos app as usual but tap on the “Albums” button 2 From the “Albums” view (tap back to Albums if you’re in Camera Roll), scroll down to find the “Sel 
+0

が、私はそれが任意の改行を挿入していない、フィドル上でそれを実行しましたがhttps://jsfiddle.net/cLk2kx02/ –

+1

@AjayPalあなたはこのコードを使用するSCSSが必要https://jsfiddle.net/cLk2kx02/1/ – DaniP

+0

おっとっと!! @ダニップ、ありがとう、私はそれに気付かなかった.. –

答えて

0

white-space: nowrap;(無改行)の後に見てみたい方法です。これは、 "大きな単語"のように長い破られないテキスト行を作成するので、前のテキストが壊れます。 <p>要素にwhite-space: nowrap;を入れてください。

+0

見てくれてありがとう!私が望む効果を得るには、p要素のラッピング動作が必要です。 –

+0

複数行テキストは複数行として保存されるべきですか?今のところ、そうではなく、あなたが言及したように「最後の行」がないからです。スパン要素の最後に3つの点を入れたいと思いますか? – Levon

+0

私は数行のテキスト(たぶん3?)と、最後の行の最後にある楕円をしたいと思っています。モバイルの場合は、5行に近いと思われます。私は終わりが行の途中や始めなどに来ることができるので、最後に行こうとしません。最後の行の最後に楕円が必要です(たとえあなたが何も言及しなかったとしても)_ –

関連する問題