<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Rookie Tutorial (runoob.com)</title> <style> div.test { white-space:nowrap; width:12em; overflow:hidden; border:1px solid #000000; } </style> </head> <body> <p>The text in the following div container cannot be fully displayed, as you can see it is clipped. </p> <p>div 使用 "text-overflow:ellipsis":</p> <div class="test" style="text-overflow:ellipsis;">This is some long text that will not fit in the box</div> <p>div 使用 "text-overflow:clip":</p> <div class="test" style="text-overflow:clip;">This is some long text that will not fit in the box</div> <p>div uses custom string "text-overflow: >>" (only works in Firefox browser):</p> <div class="test" style="text-overflow:'>>';">This is some long text that will not fit in the box</div> </body> </html>
The code effect is as follows