要点 - 如何设置嵌入式Gist的高度和宽度

时间:2014-04-09 00:41:43

标签: gist

为了在Wordpress博客中嵌入来自Github的非常长的Gists,允许我设置高度以便生成垂直滚动条的代码是什么?大约500px的东西是完美的。


编辑:问题现已解决,但我在这个问题上花了很多时间,我相信有一个专门针对该问题的线程会很有帮助。我在下面发布了一个有效的答案。

4 个答案:

答案 0 :(得分:22)

<style type="text/css">
  .gist {width:500px !important;}
  .gist-file
  .gist-data {max-height: 500px;max-width: 500px;}
</style>

<script src="https://gist.github.com/user-name/123456789.js"></script>

示例:Boilerplate网页借鉴自:http://www.dummies.com/how-to/content/a-sample-web-page-in-html.html [答案的效果与截至2016年2月24日在OSX Snow Leopard 10.6.8上的Firefox 44.0.2相同。]

<html>
<!-- Text between angle brackets is an HTML tag and is not displayed.
Most tags, such as the HTML and /HTML tags that surround the contents of
a page, come in pairs; some tags, like HR, for a horizontal rule, stand 
alone. Comments, such as the text you're reading, are not displayed when
the Web page is shown. The information between the HEAD and /HEAD tags is 
not displayed. The information between the BODY and /BODY tags is displayed.-->
<head>
<title>Enter a title, displayed at the top of the window.</title>
</head>
<!-- The information between the BODY and /BODY tags is displayed.-->
<style type="text/css">
  .gist {width:300px !important;}
  .gist-file
  .gist-data {max-height: 300px;max-width: 300px;}
</style>
<body>
<h1>Enter the main heading, usually the same as the title.</h1>
<p>Be <b>bold</b> in stating your key points. Put them in a list: </p>
<ul>
<li>The first item in your list</li>
<li>The second item; <i>italicize</i> key words</li>
</ul>
<p>Improve your image by including an image. </p>
<p><img src="http://www.mygifs.com/CoverImage.gif" alt="A Great HTML Resource"></p>
<p>Add a link to your favorite <a href="http://www.dummies.com/">Web site</a>.
Break up your page with a horizontal rule or two. </p>
<hr>
<p>Finally, link to <a href="page2.html">another page</a> in your own Web site.</p>
<!-- And add a copyright notice.-->
<p>&#169; Wiley Publishing, 2011</p>
<script src="https://gist.github.com/lawlist/12345678.js"></script>
</body>
</html>

答案 1 :(得分:8)

上述答案都不再适用。这是更新后的CSS,可以根据需要正确显示要点和可见滚动条。

.gist {
   max-width:350px;
   overflow:auto;
}

.gist .blob-wrapper.data {
   max-height:200px;
   overflow:auto;
}

请参阅此博客文章,例如: How to set custom height and width of embedded Github Gist

答案 2 :(得分:1)

他们似乎改变了一些东西,所以现在你需要这样做:

<style type="text/css"> .gist {width:500px; overflow:auto}  .gist .file-data {max-height: 500px;max-width: 500px;} </style>

答案 3 :(得分:0)

如果要点在生成的iFrame中,并且由于它是嵌入式HTML而无法访问,则可能要看一下this