隐藏Twitter关注按钮上的“followers”一词

9
有没有一种方法可以修改 Twitter 的“关注”按钮,以在气泡中显示关注者数量,但隐藏“关注者”这个词?我基本上希望我的“关注”按钮看起来和“推文”按钮相同。
当前代码如下:
<a href="https://twitter.com/User" class="twitter-follow-button" data-show-count="true" 
data-show-screen-name="false" data-dnt="true">Follow @User</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id))
{js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
2个回答

14

我遇到了同样的问题,通过隐藏“followers”这个词并在气泡的右侧创建一个假的边缘来解决了它,如果你能理解的话。因此,你需要将按钮包装在其自己的div中,然后隐藏该div的溢出,并将其宽度设置为词消失的确切点,高度精确地设置为所使用的按钮的高度。这是一个代码示例:

#titter-div {
    border-radius: 4px; /* to mimic the curved edges of the count box */
    border-right: 1px solid #AAAAAA; /* this is the width and color of the count box border */
    height: 20px; /* this height works for the medium button */
    width: 88px; /* precise width to hide the word */
    overflow: hidden; /* actually hides the word */
}

这对我来说是有效的,可以创建出你所寻找的内容。希望这可以帮到你。


理想情况下,您应该将样式声明放在样式表中,但也可以将它们内联。对于其他社交按钮,您只需调整不同的宽度、高度和边框颜色以匹配即可。 - Charles
如果您正在使用关注按钮的iframe版本,实际上您只需要将这里提到的4/5个样式添加到iframe样式参数本身中(跳过宽度,因为它已经存在)。这样,您就不需要创建一个新的div包装器 :) - Ahi Tuna
我重新审视了这个问题,发现它已经不再有效了。现在无法完美地将虚边框显示到像素级别,并且溢出会导致 div 显示比实际短,这意味着在页面内定位时必须创建偏移量。气泡内的链接还有文本装饰,下划线延伸到边框中,这暴露了这种方法的弊端。您也不能再向 div 添加填充。 - Knocks X

0
如果要在一个气泡中显示关注者的数量但隐藏“关注者”这个词,以下是我使用iframe的代码:

<iframe
  src="//platform.twitter.com/widgets/follow_button.html?screen_name=Vacance_Luberon&show_screen_name=false"
  style="width: 88px; height: 20px;"
  allowtransparency="true"
  frameborder="0"
  scrolling="no">
</iframe>



网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接