gpt4 book ai didi

twitter-bootstrap - 如何使 Google Plus 徽章具有响应性?

转载 作者:行者123 更新时间:2023-12-04 07:42:33 25 4
gpt4 key购买 nike

目前,Google Plus 徽章会自动响应宽度的变化:https://developers.google.com/+/plugins/badge/

我们的新网站设计使用 Bootstrap 进行响应式布局,我们如何才能使其具有响应性?

这是我们当前的徽章代码:

<!-- Place this tag where you want the badge to render. -->
<div class="g-plus" data-width="230" data-href="//plus.google.com/102018846923934084444" data-rel="publisher"></div>

<!-- Place this tag after the last badge tag. -->
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>

如您所见,默认宽度为 230 像素。有点困惑如何干净地做到这一点?

谢谢!

最佳答案

这对我有用。万一我们只有一个g级徽章。

<div id="google-badge" style="width: 100%">
<!-- Place this tag where you want the widget to render. -->
<div class="g-person" data-href="//plus.google.com/104771303799616655833" data-rel="author" data-width="180"></div>
<!-- Place this tag after the last widget tag. --><script type="text/javascript">
window.___gcfg = {lang: 'de'};

// just put this in here
document.getElementsByClassName('g-person')[0].setAttribute('data-width', document.getElementById('google-badge').clientWidth);

(function () {
var po = document.createElement('script');
po.type = 'text/javascript';
po.async = true;
po.src = 'https://apis.google.com/js/platform.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})();
</script>
</div>

关于twitter-bootstrap - 如何使 Google Plus 徽章具有响应性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14247643/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com