.word_wrap
{
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
Tag Archive for wrap
CSS Cross Browser Word Wrap
php word wrap function
$text = "A very long woooooooooooord."; $newtext = wordwrap($text, 8, " ", true); echo "$newtext ";
Text Wrapping with Regular Expressions
def wrap_text(txt, col = 80)
txt.gsub(/(.{1,#{col}})( +|$)
?|(.{#{col}})/,
"13
")
end
Wrap Long Lines with PRE Tag
pre {
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
word wrap
string wordwrap ( string $str [, int $width [, string $break [, bool $cut]]] ) Here, I use <br> to break the string $string every 20 chars. i.e.wordwrap($string,20, "<br /> ")
word wrap pre
/* Browser specific (not valid) styles to make preformatted text wrap */
pre {
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
Indent text after line wrap
<style type="text/css">
ul {
width: 20em;
}
li {
padding-left: 2em;
text-indent: -2em;
}
</style>
<
<ul>
<li>If we shadows have offended, think but this, and all is mended. That you have but slumbered here, while these visions did appear, and this weak and idle theme, no more yielding but a dream. Gentles, do not reprehend. If you pardon, we will mend. Else the Puck a liar call. And so good night unto you all. Give me your hands, if we be friends, and Robin shall restore amends</li>
</ul>
Wrap Text
def wrap_text(txt, col = 80)
txt.gsub(/(.{1,#{col}})( +|$
?)|(.{1,#{col}})/, "13
")
end