4
我試圖在文本被截斷時更改文本顏色。但是,還沒有成功。當文本被截斷時更改div中的文本顏色
在下面的示例中,第一個div(帶有項目符號1)應具有不同的顏色。
任何意見/建議表示讚賞。
.user-comment{
width:200px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="user-comment text-truncate">1. This is a test comment. Please do not use in production.</div>
<div class="user-comment text-truncate">2. This is not a QA.</div>
<div class="user-comment text-truncate">3. No comment found.</div>
<div class="user-comment text-truncate">4. Please ignote.</div>
你的意思是內容是> 200px,你想改變顏色? –
我想你會需要JavaScript來做到這一點。 – sol
簡短的回答 - 你需要JavaScript。這看起來類似於處理CSS溢出的https://stackoverflow.com/questions/18844192/css-only-detection-of-text-overflows-in-html。這裏有一些JS技術的鏈接。 –