简体   繁体   English

更改非WP网站上的Twitter窗口小部件高度(新API?)

[英]Change Twitter Widget Height on Non-WP Site (New API?)

I've tried searching these forums for an update on setting the widget height for the embedded Twitter widget ( https://support.twitter.com/articles/20170071 ). 我尝试在这些论坛中搜索有关设置嵌入式Twitter小部件( https://support.twitter.com/articles/20170071 )的小部件高度的更新。 You can designate a height in the setting fields on Twitter (they have a form to create a semi-custom widget), but it doesn't go into effect when I add it to my HTML. 您可以在Twitter的设置字段中指定高度(它们具有创建半定制窗口小部件的形式),但是当我将其添加到HTML中时,该高度不会生效。 Most of the forum questions on here are from 2013 (a different code from Twitter?) and don't seem to work for me. 这里出现的大多数论坛问题来自2013年(与Twitter不同的代码?),似乎对我不起作用。

I tried this JSFiddle code: 我尝试了这个JSFiddle代码:

http:// jsfiddle.net /mandykiwi/ NbF7C/ http:// jsfiddle.net / mandykiwi / NbF7C /

but setting the height to !important in CSS didn't do anything for me. 但是在CSS中将高度设置为!important对我没有任何帮助。 I may have done it wrong. 我可能做错了。 I entered this into my styles.css sheet, as per the jsfiddle code: 我根据jsfiddle代码将此输入到了styles.css工作表中:

.timeline .stream {
   height: 600px!important;
}

My HTML came from Twitter, plus some of the code they provided for further customization: 我的HTML来自Twitter,以及它们提供的一些代码以供进一步定制:

<a class="twitter-timeline" href="https://twitter.com/KGShowroom" data-widget-id="631599342176989184" data-chrome="nofooter transparent noheader noborders noscrollbar" height="600">Tweets by @KGShowroom</a>
<script>
   ! function(d, s, id) {
       var js, fjs = d.getElementsByTagName(s)[0],
           p = /^http:/.test(d.location) ? 'http' : 'https';
       if (!d.getElementById(id)) {
           js = d.createElement(s);
           js.id = id;
           js.src = p + "://platform.twitter.com/widgets.js";
           fjs.parentNode.insertBefore(js, fjs);
       }
   }(document, "script", "twitter-wjs");
</script>

(I've also tried it without the addition to the stylesheet.) (我也尝试过不添加样式表的情况。)

Another forum answer here on Stackoverflow says that the height is now set within the JS code that Twitter generates ( HTML/CSS for Twitter widget width ) but I'm not sure what that means; 关于Stackoverflow的另一个论坛答案说,高度现在是在Twitter生成的JS代码( Twitter部件宽度的HTML / CSS )中设置的,但是我不确定这是什么意思。 can it be changed? 可以改变吗?

I am not exactly sure what size I need it to be, but I know I need it larger than it is. 我不确定自己需要多大的尺寸,但是我知道我需要的尺寸要大于实际尺寸。 I'm guessing 100% in height so that it can be responsive, but even doing it in px, it isn't changing. 我猜测高度为100%,以便可以响应,但即使以px进行,它也不会改变。

This is the site I'm trying to work on this with: http://kgshowroom.com/test/index.html 这是我正在尝试使用的网站: http : //kgshowroom.com/test/index.html

iframe.twitter-timeline {

    min-height:600px!important;
}

http://jsfiddle.net/NbF7C/12/ They set min-height , so, just override it. http://jsfiddle.net/NbF7C/12/他们设置了min-height ,因此,只需覆盖它即可。

if your only need is to set a fixed height to the iframe containing the feed, you need to substitute 如果您唯一需要为包含提要的iframe设置固定高度,则需要替换为

  • height="600" with 高度=“ 600”,其中
  • data-height="600" data-height =“ 600”

in the a-html tag. 在a-html标记中。

See official configuration site, here: https://publish.twitter.com/# , and adapt your code to the result. 请参阅官方配置站点, 网址为https : //publish.twitter.com/# ,并根据结果调整代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM