The latest diary and the latest comments in the YLOG.NET homepage, the contents of the diary and the contents of the comments are often overspeed and automatically wrapped. You can only describe the two words, which makes me headache ...
The first thing I thought is to intercept one, so I wrote this function.
This operational JS, performs the server burden on the client, and the JS has speed advantage when the string is operated.
Catstring (str, len)
{
IF (str.length> len)
Str = Str.Substring (0, LEN-3, STR) "...";
Document.write (STR)
}
script>
As a result, I can imagine that because the print length of English and Chinese is different, the result is uneven, it is obviously not what I want.
Since the Chinese width is about twice the English width, then Chinese as two English characters, then intercept it, restore # @ # @% $ #! $ #
I will not post the code, n long and complicated, the most important thing is that the width of the English characters in the normal font is not the same as M and F.
Depressed for a long time, look at the layout of the CSS2.0 manual, found that there is an attribute called overflow, the original text is as follows
Overflow: Visible | Auto | Hidden | Scroll
parameter:
Visible: Do not add a scroll bar without cutting. If this default is explicitly declared, the object will be cut into the size of the Window or Frame containing the object. And the CLIP property setting will be invalid
Auto: This is the default value of the body object and TextArea. Cut the content while needing and add a scroll bar
Hidden: Does not show content of the object size
Scroll: Always display scroll bar
Description:
Search or set how to manage content when the content of the object exceeds its specified height and width.
Setting the TextArea object to hide its scroll bar for the hidden value.
For Table, if the table-layout property is set to fixed, the TD object supports overflow properties with the default value Hidden. If set to Hidden, Scroll, or Auto, the content that exceeds the TD size will be cut. If set to Visible, an additional text overflows to the lower or left (depending on the Direction property setting) unit.
Since IE5, this property is available on the Mac platform.
The corresponding script feature is Overflow. Please refer to other books I have written.
There is also an attribute that the text-overflow this property is set to Ellipsis, but only IE6 support
It seems that the problem is solved, and it is easy to write the following code according to the above attribute ....
Everyone can copy to Notepad to save into HTM file test ....
转载请注明原文地址:https://www.9cbs.com/read-29032.html