右对齐 Facebook 点赞按钮 iFrame 的内容?
我需要右对齐 Facebook Like 按钮的内容,以便它们始终位于其设置的“宽度”的骑行侧。我可以在 Firebug 中通过将表格设置为 float: right; 来做到这一点,但如果我在 CSS 中定义该值,它似乎不起作用。
这是解释我的问题的图片:
编辑:这是一个 JSFiddle:http://jsfiddle.net/h66z3/2/
I need to right align the contents of a Facebook Like button so that they always sit against the ride side of their set "width". I can do this in Firebug by setting the table to float: right;, but it doesn't appear to work if I define that value in the CSS.
Here's in image to explain my question:
EDIT: Here's a JSFiddle: http://jsfiddle.net/h66z3/2/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
由于您使用的是button_count布局,我发现有一个小技巧似乎有效。基本上你只需等待 iframe 被插入,然后将其宽度设置为 0。然后它会自动调整自身大小到合适的大小。我不能发誓这在所有情况下和所有宽度下都有效,但请测试一下,看看它是否适合您。这是一个示例代码页:
不幸的是,这不适用于标准布局,不知道为什么它如此不同。
Since you are using the button_count layout, there is a little trick I found that seems to work. Basically you just wait for the iframe to be inserted, and then set its width to 0. It will then automatically resize itself to the proper size. I can't swear this works under all circumstances and with all widths, but please test it out and see if it works for you. Here is a sample code page:
Unfortunately this doesn't work for the standard layout, not sure why it's so different.
按照德里克的建议,我使用 HTML5 版本来产生以下结果: http://jsfiddle.net/namuol /h66z3/6/
下面的源代码是通过 Facebook 的 Like 生成的按钮生成器。
JS
HTML
CSS 未更改。
Following Derek's suggestion, I used the HTML5 version instead to yield this result: http://jsfiddle.net/namuol/h66z3/6/
The source below was generated via Facebook's Like Button generator.
JS
HTML
The CSS was unchanged.
我不相信您会幸运地使用 CSS(或任何其他相关内容)来影响 Facebook 的 iFrame 的内容。我认为您要做的最好的事情就是更改 iFrame 元素本身的宽度,使其恰好适合您想要显示的 Facebook 内容量。然后右对齐整个 iFrame。
可以肯定的是,影响 iFrame 中的内容是不可能的,因为它位于不同的域中。
如果您希望它完美地向右对齐,而没有任何您自己未添加的额外空白,那么这是不会发生的。 Facebook 将在其内容末尾留出额外的空间,以容纳越来越大的“Like #”标记。
为了完美地对齐它(没有额外的空白),您只需要使用不带滚动条的“喜欢”按钮。点赞按钮本身是唯一具有恒定宽度的元素。
I don't believe you'll have any luck using CSS (or anything else for that matter) to affect the contents of Facebook's iFrame. I think the best you're going to do is changing the width of the iFrame element itself so that it JUST fits the amount of Facebook content you would like to show. And then right aligning the entire iFrame.
Pretty sure that affecting the content within the iFrame isn't possible because it's on a different domain.
If you want it to perfectly align to the right, without any extra white space that you yourself do not add, it's just not going to happen. Facebook is going to leave extra space at the end of their content to account for the Like # ticker to get bigger and bigger.
To perfectly align it (with no extra white space), you'll need to use ONLY the like button with NO ticker. The like button itself is the only element that has a constant width.
我也尝试过这样做,但因为它是一个 iframe,所以你无法更改它。我的建议是使用类似平面的按钮(我相信您使用的类似按钮会在 169k 右侧显示信息,表示您喜欢它)或更改您的设计,使其成为电子邮件 |推特 | Facebook。
我知道这很糟糕,但因为它是一个 iframe,iframe 内的所有内容都不由你掌控。
I've tried to do this as well but because it's an iframe you can't change it. My suggestion is to use either plane like button (I believe the like button you are using will display information to the right of the 169k saying you liked it) or change your design so it is Email | Twitter | Facebook.
I know it sucks but because it is an iframe everything inside the iframe is hands off for you.
检查这个例子 http://jsfiddle.net/sandeep/h66z3/3/ 可能就是这样你想要
check this example http://jsfiddle.net/sandeep/h66z3/3/ may be that's you want
正如其他人指出的那样,没有简单的方法可以做到这一点,因为内容被锁定在 iframe 内。但如果您喜欢挑战,您可能需要查看 如何让 Facebook Like 按钮的宽度自动调整大小? 是我一直在修改的一个想法。
As pointed out by others there is no easy way of doing this because the content is locked inside an iframe. But if you relish a challenge, you might want to look at How can I make the Facebook Like button's width automatically resize? for an idea I've been tinkering with.
Button_count 布局非常简单。只需在 iframe 周围放置一个 div 并将 div 设置为绝对定位且位于右侧即可。例如,
Very easy for the button_count layout. Just place a div around the iframe and set div to absolutely positioned and to the right. E.g.,