如何隐藏 google +1 按钮?

发布于 2024-11-19 21:33:55 字数 343 浏览 6 评论 0原文

我在 div 中有一个 google +1 按钮,该按钮最初应该是隐藏的,并且应该更改点击事件的可见性。 div 中的其他所有内容都工作正常,但由于某种原因,按钮不会继承 div 规则,并且它保持永久可见:

<div id="sharethisdish"> 
    ...
        <g:plusone size="small" count="false" ></g:plusone>
</div>

我尝试在 html 中为按钮提供自己的样式,并为其提供 id 并定义样式在我的 css 页面中,但它似乎不遵循任何规则。有谁知道如何更改其可见性?

I have a google +1 button in a div which is supposed to be initially hidden and should change visibility on a click event. Everything else in the div works fine but for some reason the button won't inherit the div rules and it stays permanently visible:

<div id="sharethisdish"> 
    ...
        <g:plusone size="small" count="false" ></g:plusone>
</div>

I've tried giving the button its own styling in the html as well as giving it an id and defining the styling in my css page but it doesn't seem to follow any rules. Does anyone know how to change its visibility?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦冥 2024-11-26 21:33:55

如果隐藏/显示是在单击时完成的,那么它很可能正在应用内联样式。这意味着内联样式将覆盖 css 文件中设置的样式。

您可以使用 !important 并且我相信这应该覆盖点击时应用的样式。

If the hiding/showing is being done onClick then chances are that it is applying the style inline. Which means the inline style will override the one set in your css file.

You could use !important and I believe that should override the style being applied on click.

弥繁 2024-11-26 21:33:55

这应该可以解决您的问题:

HTML:

<div id="sharethisdish">
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<g:plusone size="tall" callback="g_click_function"></g:plusone>

JS:

var d = document.getElementById("sharethisdish");
d.style.display = "none";

Now make onclick 事件将使 d.style.display = "inline";

This should solve your problem:

HTML:

<div id="sharethisdish">
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<g:plusone size="tall" callback="g_click_function"></g:plusone>

JS:

var d = document.getElementById("sharethisdish");
d.style.display = "none";

Now make onclick event that would make d.style.display = "inline";

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文