input.exam1{ text-overflow: ellipsis; } div.exam2{ width: 12em; white-space: nowrap; overflow:hidden; text-overflow:ellipsis; border:1px solid #000000; }
<p>input中使用text-overflow:ellipsis</p> <input class="exam1" type="text" value="this is a test,it will show us how text-overflow:ellipsis work"/> <p>div标签中使用text-overflow:ellipsis</p> <div class="exam2"> this is a test,it will show us how text-overflow:ellipsis </div>