Right align Facebook like button
Asked Answered
S

7

23

I am able to put a Facebook like button on my website, but how do I make it to be right-aligned within the div/iframe it is in?

I tried applying various CSS properties, but I could not get anything to move in the iframe.

Schramke answered 7/11, 2010 at 15:58 Comment(1)
You probably want to use "float: right;" but it's really hard to say without seeing what you have. Please provide your html/js code.Possum
C
3

iframe is an inline element, you can use

text-align: right

for a div that contains that iframe, or float the iframe to the right, but just make sure to clear the float afterwards.

sample: http://jsfiddle.net/Mujj6/3/
and: http://jsfiddle.net/Mujj6/5/

Cellobiose answered 7/11, 2010 at 16:21 Comment(3)
There's a problem with this, you have to set the width - you won't know the width of the box because the text is always differentIzawa
Neither text-align:right nor float:right solve the problem of a right aligned like button which should have no margin to the right border. You need to set the width, which is variable and depends on the language the button is displayed in. Sample: jsfiddle.net/Mujj6/921Exsanguinate
@Exsanguinate ... note that if your select the button that shows Like counts - that the width will also change.Winter
I
14

I think this link could help too: http://shades-of-orange.com/post/2011/01/09/Embed-Facebook-Like-Button-e28093-Right-Align-with-css-and-Settings.aspx

It says to set the width to "0". Then the box will be autoresize by Facebook and you can apply a float right to that box.

Inion answered 12/3, 2012 at 15:51 Comment(3)
Perfect, this is exactly what I was looking for that brought me here. Thanks!Beautifully
The link is dead, which is why it's always a good idea to copy and paste the relevant code in an answer.Glider
Quoting the link above: On Facebook Button Page "in the settings make sure to select width to equal 0. This leads to the facebook like button element always being the size it actually is. Which allows you to position whichever way you want, to the right for example. However there is one little trick, you still have to pull: There is a 15 pixel margin to the right of the element. You can align the button exactly to the right by giving your parent html element following css style: position:relative; right:-15px;".Cuthbertson
C
3

iframe is an inline element, you can use

text-align: right

for a div that contains that iframe, or float the iframe to the right, but just make sure to clear the float afterwards.

sample: http://jsfiddle.net/Mujj6/3/
and: http://jsfiddle.net/Mujj6/5/

Cellobiose answered 7/11, 2010 at 16:21 Comment(3)
There's a problem with this, you have to set the width - you won't know the width of the box because the text is always differentIzawa
Neither text-align:right nor float:right solve the problem of a right aligned like button which should have no margin to the right border. You need to set the width, which is variable and depends on the language the button is displayed in. Sample: jsfiddle.net/Mujj6/921Exsanguinate
@Exsanguinate ... note that if your select the button that shows Like counts - that the width will also change.Winter
P
1

What is described in Embed Facebook Like button – Right align with CSS and settings works. However, in my website, I had to change the style to

position:relative; right:-130px;
Prem answered 29/8, 2011 at 15:0 Comment(0)
S
1

Thanks for everyone's input. The position relative trick doesn't always do it for me:

div.around-fb-like{
    position:relative;
    float:right;
}

So far this has been more dependable:

#fb-root{
    position:absolute;
    left:-1000%;
}
Shellbark answered 6/9, 2012 at 9:39 Comment(0)
F
1

Seems as though there are many ways to achieve this that work in different situations.

None of the above seemed to make any difference to the position of my 'like' button, however a little trial and error with a "margin-left" tag and I got it in the right place.

Furbelow answered 21/11, 2012 at 13:44 Comment(0)
S
-1

With DIV it's easy:

.fb-like{ vertical-align:top;}

posted also on SimpleMediaCode.info ( http://e-art.lv/x/fbas )

Stingaree answered 8/12, 2011 at 10:21 Comment(0)
W
-1

the 'like' social plug-in seems to have changed styles within the iframe. what's the best way to prevent the 'like' from flowing right, on the following page?

[http://www.biographile.com/the-righteousness-and-ruin-of-science-on-this-week-in-history/16573/][1]

Watchdog answered 24/4, 2013 at 14:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.