Pinkie
Pinkie

Reputation: 10256

jQuery CSS position right not working

I have an a div with position:absolute. I'm trying to position it to right using jQuery but it's not working. In the code below i'm basically removing left and adding right:0. This should position the div to far right. using firebug, i can see the inline style being changed to right:0 but nothing is happening. What am i doing wrong. Check http://jsfiddle.net/SJP3b/1/

$('div').css({
    left: '',
    right: 0
});

Upvotes: 5

Views: 8425

Answers (3)

maycil
maycil

Reputation: 764

you have to use '0px'

$('div').css({
    left: '',
    right: '0px'
});

EDIT 1:

Sorry, For position:absolute property you can use left and top property. it not about jquery.

Upvotes: 0

Mayank
Mayank

Reputation: 5738

I don't know if right is a valid css key. if it is

$('div').css({
    left: auto,
    right: 0
});

Should work...

You can also check float:right

Upvotes: 0

jantimon
jantimon

Reputation: 38180

Use left:'auto' that works for me:

http://jsfiddle.net/SJP3b/2/

Many values can't be set to blank. So you have to set them to their default css value.

That's auto for the left attribute:

http://www.w3schools.com/css/pr_pos_left.asp

Upvotes: 10

Related Questions