javascript - Customizing Facebook Login button *USING JSSDK not FBML* - Stack Overflow

I am using the Facebook Javascript SDK to create a login button using the following markup.<div clas

I am using the Facebook Javascript SDK to create a login button using the following markup.

<div class="fb-login-button" data-show-faces="false" data-width="300px" 
     data-max-rows="1">Login with Facebook</div>

This works fine. However, I want to customise this a little bit by making it larger. I know this was possible using different values (size= for example) in the XFBML markup. I've found the correct FB css classes that need to be applied by looking at the generated html so I can always hack it with some JQuery magic.

I would much rather just set the appropriate data-* attribute and have FB-JSSDK do it on its own.

I've already tried data-size= which totally doesn't work

I am using the Facebook Javascript SDK to create a login button using the following markup.

<div class="fb-login-button" data-show-faces="false" data-width="300px" 
     data-max-rows="1">Login with Facebook</div>

This works fine. However, I want to customise this a little bit by making it larger. I know this was possible using different values (size= for example) in the XFBML markup. I've found the correct FB css classes that need to be applied by looking at the generated html so I can always hack it with some JQuery magic.

I would much rather just set the appropriate data-* attribute and have FB-JSSDK do it on its own.

I've already tried data-size= which totally doesn't work

Share Improve this question edited Nov 27, 2011 at 10:02 Jay Stevens asked Nov 22, 2011 at 15:20 Jay StevensJay Stevens 5,9239 gold badges46 silver badges68 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

I just tried data-size="large", and it worked. The style fb_button_large was applied to it, and it was slightly larger. It wasn't much larger though, I hardly noticed. Also, it's not documented so I assume it will be depreciated eventually?

data-size="xlarge" was NOTICEABLY larger, however.

<div class="fb-login-button" data-show-faces="false"
 data-max-rows="1" data-size="xlarge">Login with Facebook</div>

So, I'm not sure why it's not working for you. What I would do instead, then, is just use CSS if you want to fully customize the button.

The new button is just nested <div class="fb-login-button"><a class="fb_button"><span class="fb_button_text"> DOM construct, and you can use CSS to style it however you want.

If you are having a cascading precedence issue with the Facebook styles taking over, just use !important at the end of your style declaration to override the Facebook ones.

You can even change the size of the "F" image, since it's a sprite with multiple sizes. When you override the styles, just play with the background-position property until you get the right one.

Good luck!

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745603036a4635514.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信