英文的wordwrap

来源:互联网 发布:linux协议栈实现分析 编辑:程序博客网 时间:2024/06/10 00:17

CSS文本:word-wrap .28

语法:
word-wrap : normal | break-word
取值:
normal : 默认值。允许内容顶开指定的容器边界
break-word : 内容将在边界内换行。如果需要,词内换行( word-break )也将发生

说明:
设置或检索当当前行超过指定容器的边界时是否断开转行。
此属性仅作用于有布局的对象,如块对象。内联要素要使用该属性,必须先设定对象的 height 或 width 属性,或者设定 position 属性为 absolute ,或者设定 display 属性为 block 。
此属性对于 currentStyle 对象而言是只读的。对于其他对象而言是可读写的。
对应的脚本特性为 wordWrap 。
示例:
div { word-wrap: break-word; word-break: break-all; }

wordwrap

(PHP 4 >= 4.0.2)

wordwrap --  Wraps a string to a given number of characters using a string break character.

Description

string wordwrap ( string str [, int width [, string break [, boolean cut]]])

Returns a string with str wrapped at the column number specified by the optional width parameter. The line is broken using the (optional) break parameter.

wordwrap() will automatically wrap at column 75 and break using '/n' (newline) if width or break are not given.

If the cut is set to 1, the string is always wrapped at the specified width. So if you have a word that is larger than the given width, it is broken apart. (See second example).

注: The optional cut parameter was added in PHP 4.0.3

例子 1. wordwrap() example

<?php
$text
= "The quick brown fox jumped over the lazy dog.";
$newtext = wordwrap($text, 20, "<br />");

echo
"$newtext/n";
?>

This example would display:

The quick brown foxjumped over the lazy dog.

例子 2. wordwrap() example

<?php
$text
= "A very long woooooooooooord.";
$newtext = wordwrap($text, 8, "/n", 1);

echo
"$newtext/n";
?>

This example would display:

A verylongwoooooooooooord.
原创粉丝点击