Because my blog is mainly about code sharing, a lot of code is very long. Most of the time, I manually wrap a line. But today we can't stand it. Find a solution from the Internet. Because my blog is mainly about code sharing, many of the codes are very long. Most of the time, I manually wrap a line.
But today we can't stand it. Find a solution from the Internet.
1. css modification:
In the folder: zb_system \ ADMIN \ ueditor \ third-party \ SyntaxHighlighter
Add css in the file shcoredefault.pack.css:
The Code is as follows:
Body. syntaxhighlighter. line {white-space: pre-wrap! Important;}. syntaxhighlighter {width: 100%! Important; margin:. 3em 0. 3em 0! Important; position: relative! Important; overflow: auto! Important; background-color: # f5f5f5! Important; border: 1px solid # ccc! Important; word-break: break-all;
2. Jquery code:
$(function () { // Line wrap back var shLineWrap = function () { $('.syntaxhighlighter').each(function () { // Fetch var $sh = $(this), $gutter = $sh.find('td.gutter'), $code = $sh.find('td.code') ; // Cycle through lines $gutter.children('.line').each(function (i) { // Fetch var $gutterLine = $(this), $codeLine = $code.find('.line:nth-child(' + (i + 1) + ')') ; //alert($gutterLine); // Fetch height var height = $codeLine.height() || 0; if (!height) { height = 'auto'; } else { height = height += 'px'; //alert(height); } // Copy height over $gutterLine.attr('style', 'height: ' + height + ' !important'); // fix by Edi, for JQuery 1.7+ under Firefox 15.0 console.debug($gutterLine.height(), height, $gutterLine.text(), $codeLine); }); }); }; // Line wrap back when syntax highlighter has done it's stuff var shLineWrapWhenReady = function () { if ($('.syntaxhighlighter').length === 0) { setTimeout(shLineWrapWhenReady, 10); } else { shLineWrap(); } }; // Fire shLineWrapWhenReady();});
The above code is long code. Let's see if all of them have line breaks ??
Now, the height of the row number can be the same as that of the Code.