Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/386.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用GoogleCodePretify修饰代码的滚动条_Javascript_Scrollbar_Pretty Print - Fatal编程技术网

Javascript 使用GoogleCodePretify修饰代码的滚动条

Javascript 使用GoogleCodePretify修饰代码的滚动条,javascript,scrollbar,pretty-print,Javascript,Scrollbar,Pretty Print,我在我的博客中使用语法突出显示,这是在blogger上托管的。我的问题是,我看不到滚动条出现在预先格式化的代码块周围,即使代码太宽,无法在指定的宽度内显示。我正在用 <pre class="prettyprint lang-java prettyprinted" style=""> <code>public class MyVeryVeryLongClassname extends MyBaseClassWithAnEvenLongerName implements An

我在我的博客中使用语法突出显示,这是在blogger上托管的。我的问题是,我看不到滚动条出现在预先格式化的代码块周围,即使代码太宽,无法在指定的宽度内显示。我正在用

<pre class="prettyprint lang-java prettyprinted" style=""> <code>public class MyVeryVeryLongClassname extends MyBaseClassWithAnEvenLongerName implements AnInterface, AnotherInterface, YetAnotherInterface { </code></pre>
在我的博客上,滚动条从来没有出现过,线条超出了帖子栏的右边缘(例如,看一看),这让它看起来非常难看。StackOverflow显示的相同内容如下:

public class MyVeryVeryLongClassname extends MyBaseClassWithAnEvenLongerName implements AnInterface, AnotherInterface, YetAnotherInterface {
我用Firebug来研究stackoverflow是如何做到这一点的,我无法发现与我现在所做的有什么不同。我正在链接到与SO使用的相同的JS文件(在他们自己的CDN上)。我也用同样的风格


那么,我需要做什么才能将滚动条添加到预格式化的代码块中呢?

没关系,我找到了解决方案。我所需要做的就是将以下CSS属性添加到站点范围的CSS样式表中:

pre.prettyprint{
    width: auto;
    overflow: auto;
    max-height: 600px
}

这介绍了滚动条。

在我的, 但我使用以下CSS代码修复了它:

pre.prettyprint {
    display: block;
    overflow: auto;
    width: auto;
    /* max-height: 600px; */
    white-space: pre;
    word-wrap: normal;
    padding: 10px;   
}

我在上找到了代码。

实际上我真的不知道有什么区别,我在github上找到了这个css。