How do I make the tweet button auto-size its width so that it doesn't generate way too much "blank space" to the right


I didn’t see a tweet button category, so I have no idea which to pick - When I use the tweet button on then if there is no count, the button will render at the correct width. If I pick a count, then the button decides to be 110px, even if the tweet count is 1, or 10 or 100, leaving a lot of blank space next to the button’s area, making things look mighty ugly. Facebook manages to get this right, sizing its button widget to be only as wide as it has to be, is there a way to make the tweet button do this, too?


no bubbles:

the blue is the iframe’s background-color, illustrating the problem as well. Note that removing the iframe’s explicit width just makes it as wide as possible, which is even worse =)


Same here, no solutions in 2 weeks? :open_mouth:


I’m using AddThis for Wordpress and having the same problem. Anyone have any ideas?


At the moment, the buttons with bubbles leave a buffer space available, since the size of the count can vary. As part of dropping IE6 and 7 support we’ll be able to do something smarter, so it’s on my list to make the frame sizing flush.

In the interim though, there’s nothing you can do I’m afraid.


I found a work around:

.twitter-share-button { width: 80px !important; }

Give it a whirl! Do not make it too narrow or it will chop the count.



What about to implement postMessage event from twitter button iframe to parent window with button width and additional parameters like number from bubble?


Is there a resolution for this? Setting a fixed width won’t work after a while (where I hope that the counter would advance)…


I was able to set a fixed width on the button but whenever a page becomes popular, my counter gets chopped in half. A fixed width isn’t a great solution for me @benward


Worked for my case, thanks Dennis.


The width is set to accommodate the 1000’s of tweet’s you’re going to get - so it’s pretty much future proofed. But as mentioned above this isn’t very dynamic for the interim, and many people don’t like using fixed widths.
You can however simply disable the counter using the below code;


Please devs, do not let the people suffer from your incapability. After all those years you are not able to implement autosize on share button with counter. Even Facebook has it for a long time. Why the poor developers should be punished for this? It’s hard to explain why the Twitter button has so long space after counter and even harder explain why so many Twitter widgets are cut in half when the counter increase from 1-1000 :frowning:


Bad solution… it won’t scale anymore… so if you get too many shares things don’t fit anymore…

closed #15