text-overflow 与 word-wrap

text-overflow is used to set whether to use an omission mark (...) to mark the overflow of text within the object.

Grammar:

QQ截图20161014170051.png


But text-overflow is only used to explain how to display text when it overflows. To achieve To produce the effect of ellipses when overflowing, you must also define the forced text to be displayed in one line (white-space:nowrap) and the overflow content to be hidden (overflow:hidden). Only in this way can the effect of displaying ellipses in overflow text be achieved. The code is as follows:

text-overflow:ellipsis; 
overflow:hidden; 
white-space:nowrap;

At the same time, word-wrap can also be used to set the text behavior, whether to break the line when the current line exceeds the boundary of the specified container.

Syntax:

QQ截图20161014170100.png


normal is the browser default value, break-word is set inside a long word or URL address Perform line breaks. This attribute is not commonly used. Just use the browser default value.


Continuing Learning
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>text-overflow</title> <style type="text/css"> .test_demo{ text-overflow:ellipsis; overflow:hidden; white-space:nowrap; width:200px; background:#ccc; } </style> </head> <body> <div class="test_demo"> 超酷的IT技术学习平台(我是省略号) </div> </body> </html>
submitReset Code