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 ca开发者_运维百科n 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
});
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
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
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.
精彩评论