特定のスタイルを条件付きで要素に適用する方法はありますか?
たとえば、私が言った場合:
<div>
This text is very long, no really it is extremely long; it just goes on and on and on and on. You might say it's a bit like the Duracell(R) bunny, but without the batteries, and the floppy ears.
</div>
と
div {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
// TODO: is there any way to only apply this rule if the text is overflowing?
div {
background-color: red;
}
テキストがオーバーフローしている場合にのみ、純粋な CSS を使用して background-color: red ルールを適用する方法はありますか?
注: JavaScript を使用してこれを行う方法を確認できます。それを行うための純粋なCSSの方法があるかどうかを知りたいだけです。