2
とダイナミックテキストの隣に
私の質問は異なるが省略記号で切り詰められたテキストの後にアイコンを表示Sliding icon next to dynamic text with ellipsisアイコン省略記号
に似ています。 テキストが切り捨てられ、省略記号が表示されている場合にのみアイコンを表示します。
これは私が試したサンプルです。 https://jsfiddle.net/poonkave/6sfbhu9w/
問題は、テキストが短い場合でもアイコンが表示されます。
任意のCSSソリューションですか?
<div class="block-wrap">
<div class="block">
<div class="icon">
</div>
<div class="desc">
This is a very very very
very very very very very very very
very very very very very very
very very very very very very
very very very very very very
very very long description
</div>
</div>
.block-wrap {
display: inline-block;
max-width: 100%;
}
.block {
width: 100%;
}
.desc {
display: block;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.icon {
float: right;
margin-left: 10px;
width: 20px;
height: 14px;
background-color: #333;
}
解決方法がありますが、javascriptを使用する必要があります。http://stackoverflow.com/questions/7738117/html-text-overflow-ellipsis-detection – Banzay