Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- averyvery­longword
- averyverylongword
- averyvery-
- longword
- /([^s-]{5})([^s-]{5})/ → $1­$2
- .word-break {
- /* The following styles prevent unbroken strings from breaking the layout */
- width: 300px; /* set to whatever width you need */
- overflow: auto;
- white-space: -moz-pre-wrap; /* Mozilla */
- white-space: -hp-pre-wrap; /* HP printers */
- white-space: -o-pre-wrap; /* Opera 7 */
- white-space: -pre-wrap; /* Opera 4-6 */
- white-space: pre-wrap; /* CSS 2.1 */
- white-space: pre-line; /* CSS 3 (and 2.1 as well, actually) */
- word-wrap: break-word; /* IE */
- -moz-binding: url('xbl.xml#wordwrap'); /* Firefox (using XBL) */
- }
- <?xml version="1.0" encoding="utf-8"?>
- <bindings xmlns="http://www.mozilla.org/xbl"
- xmlns:html="http://www.w3.org/1999/xhtml">
- <!--
- More information on XBL:
- http://developer.mozilla.org/en/docs/XBL:XBL_1.0_Reference
- Example of implementing the CSS 'word-wrap' feature:
- http://blog.stchur.com/2007/02/22/emulating-css-word-wrap-for-mozillafirefox/
- -->
- <binding id="wordwrap" applyauthorstyles="false">
- <implementation>
- <constructor>
- //<![CDATA[
- var elem = this;
- doWrap();
- elem.addEventListener('overflow', doWrap, false);
- function doWrap() {
- var walker = document.createTreeWalker(elem, NodeFilter.SHOW_TEXT, null, false);
- while (walker.nextNode()) {
- var node = walker.currentNode;
- node.nodeValue = node.nodeValue.split('').join(String.fromCharCode('8203'));
- }
- }
- //]]>
- </constructor>
- </implementation>
- </binding>
- </bindings>
- .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+ */
- }
- #consumeralerts_leftcol{
- float:left;
- width: 250px;
- margin-bottom:10px;
- word-wrap: break-word;
- }
- word-wrap: break-word;
- overflow: hidden;
- <style type="text/css">
- .cell {
- float: left;
- width: 100px;
- border: 1px solid;
- line-height: 1em;
- }
- </style>
- <div class="cell">TopLeft</div>
- <div class="cell">TopMiddlePlusSomeOtherTextWhichMakesItToLong</div>
- <div class="cell">TopRight</div>
- <br/>
- <div class="cell">BottomLeft</div>
- <div class="cell">BottomMiddle</div>
- <div class="cell">bottomRight</div>
- <style type="text/css">
- .column {
- float: left;
- min-width: 100px;
- }
- .cell2 {
- border: 1px solid;
- line-height: 1em;
- }
- </style>
- <div class="column">
- <div class="cell2">TopLeft</div>
- <div class="cell2">BottomLeft</div>
- </div>
- <div class="column">
- <div class="cell2">TopMiddlePlusSomeOtherTextWhichMakesItToLong</div>
- <div class="cell2">BottomMiddle</div>
- </div>
- <div class="column">
- <div class="cell2">TopRight</div>
- <div class="cell2">bottomRight</div>
- </div>
- <br/>
- 'abcde12345678901234'.replace(/([^s-]{5})([^s-]{5})/g, '$1­$2')
- abcde­12345678901234
- .replace(/([^s-]{5})(?=[^s-])/g, '$1­')
- abcde­12345­67890­1234
- makeWrappable = function(str, position)
- {
- if (!str)
- return '';
- position = position || 15; // default to breaking after 15 chars
- // matches every requested number of chars that's not whitespace or one of the special chars defined below
- var longRunsRegex = cachedRegex('([^\s\./\,_@\|-]{' + position + '})(?=[^\s\./\,_@\|-])', 'g');
- return str
- .replace(longRunsRegex, '$1​') // put a zero-width space every requested number of chars that's not whitespace or a special char
- .replace(makeWrappable.SPECIAL_CHARS_REGEX, '$1​'); // and one after special chars we want to allow breaking after
- };
- makeWrappable.SPECIAL_CHARS_REGEX = /([./\,_@|-])/g; // period, forward slash, backslash, comma, underscore, @, |, hyphen
- cachedRegex = function(reString, reFlags)
- {
- var key = reString + (reFlags ? ':::' + reFlags : '');
- if (!cachedRegex.cache[key])
- cachedRegex.cache[key] = new RegExp(reString, reFlags);
- return cachedRegex.cache[key];
- };
- cachedRegex.cache = {};
- makeWrappable('12345678901234567890 12345678901234567890 1234567890/1234567890')
Add Comment
Please, Sign In to add comment