2011-09-22 70 views
14

我想弄清楚如何修改谷歌加1按鈕的寬度...調整寬度的谷歌加1按鈕

在文件說,你可以設置一個寬度。

目前,當我檢查使用Firebug的元素...它說寬度設置爲90px,我希望設置爲70px ...是可能的嗎?

<!-- Place this tag where you want the +1 button to render --> 
    <g:plusone size="medium"></g:plusone> 

    <!-- Place this render call where appropriate --> 
    <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> 

回答

12

不知道iframe id是否總是相同,但如果是的話,您可以使用css +!important重寫元素樣式。類似於:

/* this overrides 90px to 72px width to +1 button */ 
#___plusone_0{ width:72px !important; } 

希望它有幫助。

+1

對我的作品!只要把'#___ plusone_0 {width:72px!important; ''在你的CSS中 – FLY

1

我很沮喪的按鈕不都是相同的大小,所以我通過css + javascript管理得到32x32 +1按鈕的工作。你可以在這裏的細節:

http://bashireghbali.com/technology/google-plus-one-button-32x32/

注意,在頁面重新加載它不會顯示已完成+1狀態(無回調對於尚未除非有人知道一個尚未發佈一)

17

的ID ISN 「T總是相同的,如果你使用一個以上的按鈕,這樣你可以使用CSS的該位趕上多個按鈕:

[id^=___plusone] { width:72px !important; } 

這適用於具有與___plusone開頭的ID的所有元素,這似乎成爲Google的納姆按鈕的空間

1

我發現如果你不是試圖改變物理按鈕的寬度,而只是試圖使寬度更小來調整定位。

的最好方法是設置:

#id_of_button { 位置:相對; 左:(無論哪個效果最好)px }

希望有所幫助。

0

這裏的答案越來越老了,所以我想放棄一個註釋,說明可能性,以對齊谷歌的內容和一個按鈕。

所以,如果像我一樣,你試圖強制寬度,以任何大小在右側對齊忘記它,並使用align="right"而不是!

<g:plusone align="right" size="medium"></g:plusone> 

此處瞭解詳情:https://developers.google.com/+/web/+1button/